
obj/user/testshell:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 73 05 00 00       	call   8005a4 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <wrong>:
	breakpoint();
}

void
wrong(int rfd, int kfd, int off)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	57                   	push   %edi
  800044:	56                   	push   %esi
  800045:	53                   	push   %ebx
  800046:	81 ec 8c 00 00 00    	sub    $0x8c,%esp
  80004c:	8b 7d 08             	mov    0x8(%ebp),%edi
  80004f:	8b 75 0c             	mov    0xc(%ebp),%esi
  800052:	8b 5d 10             	mov    0x10(%ebp),%ebx
	char buf[100];
	int n;

	seek(rfd, off);
  800055:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800059:	89 3c 24             	mov    %edi,(%esp)
  80005c:	e8 b4 1a 00 00       	call   801b15 <seek>
	seek(kfd, off);
  800061:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800065:	89 34 24             	mov    %esi,(%esp)
  800068:	e8 a8 1a 00 00       	call   801b15 <seek>

	cprintf("shell produced incorrect output.\n");
  80006d:	c7 04 24 c0 36 80 00 	movl   $0x8036c0,(%esp)
  800074:	e8 5c 06 00 00       	call   8006d5 <cprintf>
	cprintf("expected:\n===\n");
  800079:	c7 04 24 5b 37 80 00 	movl   $0x80375b,(%esp)
  800080:	e8 50 06 00 00       	call   8006d5 <cprintf>
	while ((n = read(kfd, buf, sizeof buf-1)) > 0)
  800085:	8d 5d 84             	lea    -0x7c(%ebp),%ebx
  800088:	eb 0c                	jmp    800096 <wrong+0x56>
		sys_cputs(buf, n);
  80008a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80008e:	89 1c 24             	mov    %ebx,(%esp)
  800091:	e8 0a 11 00 00       	call   8011a0 <sys_cputs>
	seek(rfd, off);
	seek(kfd, off);

	cprintf("shell produced incorrect output.\n");
	cprintf("expected:\n===\n");
	while ((n = read(kfd, buf, sizeof buf-1)) > 0)
  800096:	c7 44 24 08 63 00 00 	movl   $0x63,0x8(%esp)
  80009d:	00 
  80009e:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8000a2:	89 34 24             	mov    %esi,(%esp)
  8000a5:	e8 89 1c 00 00       	call   801d33 <read>
  8000aa:	85 c0                	test   %eax,%eax
  8000ac:	7f dc                	jg     80008a <wrong+0x4a>
		sys_cputs(buf, n);
	cprintf("===\ngot:\n===\n");
  8000ae:	c7 04 24 6a 37 80 00 	movl   $0x80376a,(%esp)
  8000b5:	e8 1b 06 00 00       	call   8006d5 <cprintf>
	while ((n = read(rfd, buf, sizeof buf-1)) > 0)
  8000ba:	8d 5d 84             	lea    -0x7c(%ebp),%ebx
  8000bd:	eb 0c                	jmp    8000cb <wrong+0x8b>
		sys_cputs(buf, n);
  8000bf:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000c3:	89 1c 24             	mov    %ebx,(%esp)
  8000c6:	e8 d5 10 00 00       	call   8011a0 <sys_cputs>
	cprintf("shell produced incorrect output.\n");
	cprintf("expected:\n===\n");
	while ((n = read(kfd, buf, sizeof buf-1)) > 0)
		sys_cputs(buf, n);
	cprintf("===\ngot:\n===\n");
	while ((n = read(rfd, buf, sizeof buf-1)) > 0)
  8000cb:	c7 44 24 08 63 00 00 	movl   $0x63,0x8(%esp)
  8000d2:	00 
  8000d3:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8000d7:	89 3c 24             	mov    %edi,(%esp)
  8000da:	e8 54 1c 00 00       	call   801d33 <read>
  8000df:	85 c0                	test   %eax,%eax
  8000e1:	7f dc                	jg     8000bf <wrong+0x7f>
		sys_cputs(buf, n);
	cprintf("===\n");
  8000e3:	c7 04 24 65 37 80 00 	movl   $0x803765,(%esp)
  8000ea:	e8 e6 05 00 00       	call   8006d5 <cprintf>
	exit();
  8000ef:	e8 00 05 00 00       	call   8005f4 <exit>
}
  8000f4:	81 c4 8c 00 00 00    	add    $0x8c,%esp
  8000fa:	5b                   	pop    %ebx
  8000fb:	5e                   	pop    %esi
  8000fc:	5f                   	pop    %edi
  8000fd:	5d                   	pop    %ebp
  8000fe:	c3                   	ret    

008000ff <umain>:

void wrong(int, int, int);

void
umain(void)
{
  8000ff:	55                   	push   %ebp
  800100:	89 e5                	mov    %esp,%ebp
  800102:	57                   	push   %edi
  800103:	56                   	push   %esi
  800104:	53                   	push   %ebx
  800105:	83 ec 3c             	sub    $0x3c,%esp
	char c1, c2;
	int r, rfd, wfd, kfd, n1, n2, off, nloff;

	close(0);
  800108:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80010f:	e8 d8 1d 00 00       	call   801eec <close>
	close(1);
  800114:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  80011b:	e8 cc 1d 00 00       	call   801eec <close>
	opencons();
  800120:	e8 c2 03 00 00       	call   8004e7 <opencons>
	opencons();
  800125:	e8 bd 03 00 00       	call   8004e7 <opencons>

	if ((rfd = open("testshell.sh", O_RDONLY)) < 0)
  80012a:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800131:	00 
  800132:	c7 04 24 78 37 80 00 	movl   $0x803778,(%esp)
  800139:	e8 7e 21 00 00       	call   8022bc <open>
  80013e:	89 c6                	mov    %eax,%esi
  800140:	85 c0                	test   %eax,%eax
  800142:	79 20                	jns    800164 <umain+0x65>
		panic("open testshell.sh: %e", rfd);
  800144:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800148:	c7 44 24 08 85 37 80 	movl   $0x803785,0x8(%esp)
  80014f:	00 
  800150:	c7 44 24 04 12 00 00 	movl   $0x12,0x4(%esp)
  800157:	00 
  800158:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  80015f:	e8 ac 04 00 00       	call   800610 <_panic>
	if ((wfd = open("testshell.out", O_WRONLY|O_CREAT|O_TRUNC)) < 0)
  800164:	c7 44 24 04 01 03 00 	movl   $0x301,0x4(%esp)
  80016b:	00 
  80016c:	c7 04 24 ac 37 80 00 	movl   $0x8037ac,(%esp)
  800173:	e8 44 21 00 00       	call   8022bc <open>
  800178:	89 c7                	mov    %eax,%edi
  80017a:	85 c0                	test   %eax,%eax
  80017c:	79 20                	jns    80019e <umain+0x9f>
		panic("open testshell.out: %e", wfd);
  80017e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800182:	c7 44 24 08 ba 37 80 	movl   $0x8037ba,0x8(%esp)
  800189:	00 
  80018a:	c7 44 24 04 14 00 00 	movl   $0x14,0x4(%esp)
  800191:	00 
  800192:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  800199:	e8 72 04 00 00       	call   800610 <_panic>

	cprintf("running sh -x < testshell.sh > testshell.out\n");
  80019e:	c7 04 24 e4 36 80 00 	movl   $0x8036e4,(%esp)
  8001a5:	e8 2b 05 00 00       	call   8006d5 <cprintf>
	if ((r = fork()) < 0)
  8001aa:	e8 a3 14 00 00       	call   801652 <fork>
  8001af:	89 c3                	mov    %eax,%ebx
  8001b1:	85 c0                	test   %eax,%eax
  8001b3:	79 20                	jns    8001d5 <umain+0xd6>
		panic("fork: %e", r);
  8001b5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001b9:	c7 44 24 08 d1 37 80 	movl   $0x8037d1,0x8(%esp)
  8001c0:	00 
  8001c1:	c7 44 24 04 18 00 00 	movl   $0x18,0x4(%esp)
  8001c8:	00 
  8001c9:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  8001d0:	e8 3b 04 00 00       	call   800610 <_panic>
	if (r == 0) {
  8001d5:	85 c0                	test   %eax,%eax
  8001d7:	0f 85 9f 00 00 00    	jne    80027c <umain+0x17d>
		dup(rfd, 0);
  8001dd:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8001e4:	00 
  8001e5:	89 34 24             	mov    %esi,(%esp)
  8001e8:	e8 9e 1d 00 00       	call   801f8b <dup>
		dup(wfd, 1);
  8001ed:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8001f4:	00 
  8001f5:	89 3c 24             	mov    %edi,(%esp)
  8001f8:	e8 8e 1d 00 00       	call   801f8b <dup>
		close(rfd);
  8001fd:	89 34 24             	mov    %esi,(%esp)
  800200:	e8 e7 1c 00 00       	call   801eec <close>
		close(wfd);
  800205:	89 3c 24             	mov    %edi,(%esp)
  800208:	e8 df 1c 00 00       	call   801eec <close>
		if ((r = spawnl("/sh", "sh", "-x", 0)) < 0)
  80020d:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  800214:	00 
  800215:	c7 44 24 08 da 37 80 	movl   $0x8037da,0x8(%esp)
  80021c:	00 
  80021d:	c7 44 24 04 82 37 80 	movl   $0x803782,0x4(%esp)
  800224:	00 
  800225:	c7 04 24 dd 37 80 00 	movl   $0x8037dd,(%esp)
  80022c:	e8 33 27 00 00       	call   802964 <spawnl>
  800231:	89 c3                	mov    %eax,%ebx
  800233:	85 c0                	test   %eax,%eax
  800235:	79 20                	jns    800257 <umain+0x158>
			panic("spawn: %e", r);
  800237:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80023b:	c7 44 24 08 e1 37 80 	movl   $0x8037e1,0x8(%esp)
  800242:	00 
  800243:	c7 44 24 04 1f 00 00 	movl   $0x1f,0x4(%esp)
  80024a:	00 
  80024b:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  800252:	e8 b9 03 00 00       	call   800610 <_panic>
		close(0);
  800257:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80025e:	e8 89 1c 00 00       	call   801eec <close>
		close(1);
  800263:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  80026a:	e8 7d 1c 00 00       	call   801eec <close>
		wait(r);
  80026f:	89 1c 24             	mov    %ebx,(%esp)
  800272:	e8 bd 2f 00 00       	call   803234 <wait>
		exit();
  800277:	e8 78 03 00 00       	call   8005f4 <exit>
	}
	close(rfd);
  80027c:	89 34 24             	mov    %esi,(%esp)
  80027f:	e8 68 1c 00 00       	call   801eec <close>
	close(wfd);
  800284:	89 3c 24             	mov    %edi,(%esp)
  800287:	e8 60 1c 00 00       	call   801eec <close>
	wait(r);
  80028c:	89 1c 24             	mov    %ebx,(%esp)
  80028f:	e8 a0 2f 00 00       	call   803234 <wait>

	if ((rfd = open("testshell.out", O_RDONLY)) < 0)
  800294:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80029b:	00 
  80029c:	c7 04 24 ac 37 80 00 	movl   $0x8037ac,(%esp)
  8002a3:	e8 14 20 00 00       	call   8022bc <open>
  8002a8:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  8002ab:	85 c0                	test   %eax,%eax
  8002ad:	79 20                	jns    8002cf <umain+0x1d0>
		panic("open testshell.out for reading: %e", rfd);
  8002af:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002b3:	c7 44 24 08 14 37 80 	movl   $0x803714,0x8(%esp)
  8002ba:	00 
  8002bb:	c7 44 24 04 2a 00 00 	movl   $0x2a,0x4(%esp)
  8002c2:	00 
  8002c3:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  8002ca:	e8 41 03 00 00       	call   800610 <_panic>
	if ((kfd = open("testshell.key", O_RDONLY)) < 0)
  8002cf:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8002d6:	00 
  8002d7:	c7 04 24 eb 37 80 00 	movl   $0x8037eb,(%esp)
  8002de:	e8 d9 1f 00 00       	call   8022bc <open>
  8002e3:	89 45 d0             	mov    %eax,-0x30(%ebp)
  8002e6:	85 c0                	test   %eax,%eax
  8002e8:	79 20                	jns    80030a <umain+0x20b>
		panic("open testshell.key for reading: %e", kfd);
  8002ea:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002ee:	c7 44 24 08 38 37 80 	movl   $0x803738,0x8(%esp)
  8002f5:	00 
  8002f6:	c7 44 24 04 2c 00 00 	movl   $0x2c,0x4(%esp)
  8002fd:	00 
  8002fe:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  800305:	e8 06 03 00 00       	call   800610 <_panic>
  80030a:	bf 01 00 00 00       	mov    $0x1,%edi
  80030f:	be 00 00 00 00       	mov    $0x0,%esi

	nloff = 0;
	for (off=0;; off++) {
		n1 = read(rfd, &c1, 1);
  800314:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  80031b:	00 
  80031c:	8d 45 e7             	lea    -0x19(%ebp),%eax
  80031f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800323:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  800326:	89 04 24             	mov    %eax,(%esp)
  800329:	e8 05 1a 00 00       	call   801d33 <read>
  80032e:	89 c3                	mov    %eax,%ebx
		n2 = read(kfd, &c2, 1);
  800330:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  800337:	00 
  800338:	8d 45 e6             	lea    -0x1a(%ebp),%eax
  80033b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80033f:	8b 45 d0             	mov    -0x30(%ebp),%eax
  800342:	89 04 24             	mov    %eax,(%esp)
  800345:	e8 e9 19 00 00       	call   801d33 <read>
		if (n1 < 0)
  80034a:	85 db                	test   %ebx,%ebx
  80034c:	79 20                	jns    80036e <umain+0x26f>
			panic("reading testshell.out: %e", n1);
  80034e:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800352:	c7 44 24 08 f9 37 80 	movl   $0x8037f9,0x8(%esp)
  800359:	00 
  80035a:	c7 44 24 04 33 00 00 	movl   $0x33,0x4(%esp)
  800361:	00 
  800362:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  800369:	e8 a2 02 00 00       	call   800610 <_panic>
		if (n2 < 0)
  80036e:	85 c0                	test   %eax,%eax
  800370:	79 20                	jns    800392 <umain+0x293>
			panic("reading testshell.key: %e", n2);
  800372:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800376:	c7 44 24 08 13 38 80 	movl   $0x803813,0x8(%esp)
  80037d:	00 
  80037e:	c7 44 24 04 35 00 00 	movl   $0x35,0x4(%esp)
  800385:	00 
  800386:	c7 04 24 9b 37 80 00 	movl   $0x80379b,(%esp)
  80038d:	e8 7e 02 00 00       	call   800610 <_panic>
		if (n1 == 0 && n2 == 0)
  800392:	85 c0                	test   %eax,%eax
  800394:	75 04                	jne    80039a <umain+0x29b>
  800396:	85 db                	test   %ebx,%ebx
  800398:	74 3d                	je     8003d7 <umain+0x2d8>
			break;
		if (n1 != 1 || n2 != 1 || c1 != c2)
  80039a:	83 fb 01             	cmp    $0x1,%ebx
  80039d:	8d 76 00             	lea    0x0(%esi),%esi
  8003a0:	75 10                	jne    8003b2 <umain+0x2b3>
  8003a2:	83 f8 01             	cmp    $0x1,%eax
  8003a5:	75 0b                	jne    8003b2 <umain+0x2b3>
  8003a7:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
  8003ab:	3a 45 e6             	cmp    -0x1a(%ebp),%al
  8003ae:	66 90                	xchg   %ax,%ax
  8003b0:	74 16                	je     8003c8 <umain+0x2c9>
			wrong(rfd, kfd, nloff);
  8003b2:	89 74 24 08          	mov    %esi,0x8(%esp)
  8003b6:	8b 45 d0             	mov    -0x30(%ebp),%eax
  8003b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003bd:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8003c0:	89 04 24             	mov    %eax,(%esp)
  8003c3:	e8 78 fc ff ff       	call   800040 <wrong>
		if (c1 == '\n')
  8003c8:	80 7d e7 0a          	cmpb   $0xa,-0x19(%ebp)
  8003cc:	0f 44 f7             	cmove  %edi,%esi
  8003cf:	83 c7 01             	add    $0x1,%edi
			nloff = off+1;
	}
  8003d2:	e9 3d ff ff ff       	jmp    800314 <umain+0x215>
	cprintf("shell ran correctly\n");			
  8003d7:	c7 04 24 2d 38 80 00 	movl   $0x80382d,(%esp)
  8003de:	e8 f2 02 00 00       	call   8006d5 <cprintf>
static __inline uint64_t read_tsc(void) __attribute__((always_inline));

static __inline void
breakpoint(void)
{
	__asm __volatile("int3");
  8003e3:	cc                   	int3   

	breakpoint();
}
  8003e4:	83 c4 3c             	add    $0x3c,%esp
  8003e7:	5b                   	pop    %ebx
  8003e8:	5e                   	pop    %esi
  8003e9:	5f                   	pop    %edi
  8003ea:	5d                   	pop    %ebp
  8003eb:	c3                   	ret    
  8003ec:	00 00                	add    %al,(%eax)
	...

008003f0 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  8003f0:	55                   	push   %ebp
  8003f1:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  8003f3:	b8 00 00 00 00       	mov    $0x0,%eax
  8003f8:	5d                   	pop    %ebp
  8003f9:	c3                   	ret    

008003fa <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  8003fa:	55                   	push   %ebp
  8003fb:	89 e5                	mov    %esp,%ebp
  8003fd:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  800400:	c7 44 24 04 42 38 80 	movl   $0x803842,0x4(%esp)
  800407:	00 
  800408:	8b 45 0c             	mov    0xc(%ebp),%eax
  80040b:	89 04 24             	mov    %eax,(%esp)
  80040e:	e8 97 09 00 00       	call   800daa <strcpy>
	return 0;
}
  800413:	b8 00 00 00 00       	mov    $0x0,%eax
  800418:	c9                   	leave  
  800419:	c3                   	ret    

0080041a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80041a:	55                   	push   %ebp
  80041b:	89 e5                	mov    %esp,%ebp
  80041d:	57                   	push   %edi
  80041e:	56                   	push   %esi
  80041f:	53                   	push   %ebx
  800420:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  800426:	b8 00 00 00 00       	mov    $0x0,%eax
  80042b:	be 00 00 00 00       	mov    $0x0,%esi
  800430:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  800434:	74 41                	je     800477 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  800436:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80043c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80043f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  800441:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  800447:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80044c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80044f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800453:	03 45 0c             	add    0xc(%ebp),%eax
  800456:	89 44 24 04          	mov    %eax,0x4(%esp)
  80045a:	89 3c 24             	mov    %edi,(%esp)
  80045d:	e8 03 0b 00 00       	call   800f65 <memmove>
		sys_cputs(buf, m);
  800462:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800466:	89 3c 24             	mov    %edi,(%esp)
  800469:	e8 32 0d 00 00       	call   8011a0 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  80046e:	01 de                	add    %ebx,%esi
  800470:	89 f0                	mov    %esi,%eax
  800472:	3b 75 10             	cmp    0x10(%ebp),%esi
  800475:	72 c5                	jb     80043c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  800477:	89 f0                	mov    %esi,%eax
  800479:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  80047f:	5b                   	pop    %ebx
  800480:	5e                   	pop    %esi
  800481:	5f                   	pop    %edi
  800482:	5d                   	pop    %ebp
  800483:	c3                   	ret    

00800484 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  800484:	55                   	push   %ebp
  800485:	89 e5                	mov    %esp,%ebp
  800487:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  80048a:	8b 45 08             	mov    0x8(%ebp),%eax
  80048d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  800490:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  800497:	00 
  800498:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80049b:	89 04 24             	mov    %eax,(%esp)
  80049e:	e8 fd 0c 00 00       	call   8011a0 <sys_cputs>
}
  8004a3:	c9                   	leave  
  8004a4:	c3                   	ret    

008004a5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8004a5:	55                   	push   %ebp
  8004a6:	89 e5                	mov    %esp,%ebp
  8004a8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8004ab:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8004af:	75 07                	jne    8004b8 <devcons_read+0x13>
  8004b1:	eb 2d                	jmp    8004e0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8004b3:	e8 ad 10 00 00       	call   801565 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8004b8:	90                   	nop
  8004b9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8004c0:	e8 a7 0c 00 00       	call   80116c <sys_cgetc>
  8004c5:	85 c0                	test   %eax,%eax
  8004c7:	74 ea                	je     8004b3 <devcons_read+0xe>
  8004c9:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  8004cb:	85 c0                	test   %eax,%eax
  8004cd:	78 16                	js     8004e5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  8004cf:	83 f8 04             	cmp    $0x4,%eax
  8004d2:	74 0c                	je     8004e0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  8004d4:	8b 45 0c             	mov    0xc(%ebp),%eax
  8004d7:	88 10                	mov    %dl,(%eax)
  8004d9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  8004de:	eb 05                	jmp    8004e5 <devcons_read+0x40>
  8004e0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8004e5:	c9                   	leave  
  8004e6:	c3                   	ret    

008004e7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  8004e7:	55                   	push   %ebp
  8004e8:	89 e5                	mov    %esp,%ebp
  8004ea:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  8004ed:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8004f0:	89 04 24             	mov    %eax,(%esp)
  8004f3:	e8 63 15 00 00       	call   801a5b <fd_alloc>
  8004f8:	85 c0                	test   %eax,%eax
  8004fa:	78 3f                	js     80053b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  8004fc:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  800503:	00 
  800504:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800507:	89 44 24 04          	mov    %eax,0x4(%esp)
  80050b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800512:	e8 ef 0f 00 00       	call   801506 <sys_page_alloc>
  800517:	85 c0                	test   %eax,%eax
  800519:	78 20                	js     80053b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80051b:	8b 15 00 70 80 00    	mov    0x807000,%edx
  800521:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800524:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  800526:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800529:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  800530:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800533:	89 04 24             	mov    %eax,(%esp)
  800536:	e8 f5 14 00 00       	call   801a30 <fd2num>
}
  80053b:	c9                   	leave  
  80053c:	c3                   	ret    

0080053d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80053d:	55                   	push   %ebp
  80053e:	89 e5                	mov    %esp,%ebp
  800540:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  800543:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800546:	89 44 24 04          	mov    %eax,0x4(%esp)
  80054a:	8b 45 08             	mov    0x8(%ebp),%eax
  80054d:	89 04 24             	mov    %eax,(%esp)
  800550:	e8 78 15 00 00       	call   801acd <fd_lookup>
  800555:	85 c0                	test   %eax,%eax
  800557:	78 11                	js     80056a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  800559:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80055c:	8b 00                	mov    (%eax),%eax
  80055e:	3b 05 00 70 80 00    	cmp    0x807000,%eax
  800564:	0f 94 c0             	sete   %al
  800567:	0f b6 c0             	movzbl %al,%eax
}
  80056a:	c9                   	leave  
  80056b:	c3                   	ret    

0080056c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  80056c:	55                   	push   %ebp
  80056d:	89 e5                	mov    %esp,%ebp
  80056f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  800572:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  800579:	00 
  80057a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80057d:	89 44 24 04          	mov    %eax,0x4(%esp)
  800581:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800588:	e8 a6 17 00 00       	call   801d33 <read>
	if (r < 0)
  80058d:	85 c0                	test   %eax,%eax
  80058f:	78 0f                	js     8005a0 <getchar+0x34>
		return r;
	if (r < 1)
  800591:	85 c0                	test   %eax,%eax
  800593:	7f 07                	jg     80059c <getchar+0x30>
  800595:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  80059a:	eb 04                	jmp    8005a0 <getchar+0x34>
		return -E_EOF;
	return c;
  80059c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8005a0:	c9                   	leave  
  8005a1:	c3                   	ret    
	...

008005a4 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  8005a4:	55                   	push   %ebp
  8005a5:	89 e5                	mov    %esp,%ebp
  8005a7:	83 ec 18             	sub    $0x18,%esp
  8005aa:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8005ad:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8005b0:	8b 75 08             	mov    0x8(%ebp),%esi
  8005b3:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  8005b6:	e8 de 0f 00 00       	call   801599 <sys_getenvid>
	env = &envs [ENVX(envid)];
  8005bb:	25 ff 03 00 00       	and    $0x3ff,%eax
  8005c0:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8005c3:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8005c8:	a3 74 70 80 00       	mov    %eax,0x807074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8005cd:	85 f6                	test   %esi,%esi
  8005cf:	7e 07                	jle    8005d8 <libmain+0x34>
		binaryname = argv[0];
  8005d1:	8b 03                	mov    (%ebx),%eax
  8005d3:	a3 1c 70 80 00       	mov    %eax,0x80701c

	// call user main routine
	umain(argc, argv);
  8005d8:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8005dc:	89 34 24             	mov    %esi,(%esp)
  8005df:	e8 1b fb ff ff       	call   8000ff <umain>

	// exit gracefully
	exit();
  8005e4:	e8 0b 00 00 00       	call   8005f4 <exit>
}
  8005e9:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8005ec:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8005ef:	89 ec                	mov    %ebp,%esp
  8005f1:	5d                   	pop    %ebp
  8005f2:	c3                   	ret    
	...

008005f4 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  8005f4:	55                   	push   %ebp
  8005f5:	89 e5                	mov    %esp,%ebp
  8005f7:	83 ec 18             	sub    $0x18,%esp
	close_all();
  8005fa:	e8 6a 19 00 00       	call   801f69 <close_all>
	sys_env_destroy(0);
  8005ff:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800606:	e8 c2 0f 00 00       	call   8015cd <sys_env_destroy>
}
  80060b:	c9                   	leave  
  80060c:	c3                   	ret    
  80060d:	00 00                	add    %al,(%eax)
	...

00800610 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  800610:	55                   	push   %ebp
  800611:	89 e5                	mov    %esp,%ebp
  800613:	53                   	push   %ebx
  800614:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800617:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  80061a:	a1 78 70 80 00       	mov    0x807078,%eax
  80061f:	85 c0                	test   %eax,%eax
  800621:	74 10                	je     800633 <_panic+0x23>
		cprintf("%s: ", argv0);
  800623:	89 44 24 04          	mov    %eax,0x4(%esp)
  800627:	c7 04 24 65 38 80 00 	movl   $0x803865,(%esp)
  80062e:	e8 a2 00 00 00       	call   8006d5 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  800633:	8b 45 0c             	mov    0xc(%ebp),%eax
  800636:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80063a:	8b 45 08             	mov    0x8(%ebp),%eax
  80063d:	89 44 24 08          	mov    %eax,0x8(%esp)
  800641:	a1 1c 70 80 00       	mov    0x80701c,%eax
  800646:	89 44 24 04          	mov    %eax,0x4(%esp)
  80064a:	c7 04 24 6a 38 80 00 	movl   $0x80386a,(%esp)
  800651:	e8 7f 00 00 00       	call   8006d5 <cprintf>
	vcprintf(fmt, ap);
  800656:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80065a:	8b 45 10             	mov    0x10(%ebp),%eax
  80065d:	89 04 24             	mov    %eax,(%esp)
  800660:	e8 0f 00 00 00       	call   800674 <vcprintf>
	cprintf("\n");
  800665:	c7 04 24 68 37 80 00 	movl   $0x803768,(%esp)
  80066c:	e8 64 00 00 00       	call   8006d5 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800671:	cc                   	int3   
  800672:	eb fd                	jmp    800671 <_panic+0x61>

00800674 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800674:	55                   	push   %ebp
  800675:	89 e5                	mov    %esp,%ebp
  800677:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  80067d:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800684:	00 00 00 
	b.cnt = 0;
  800687:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  80068e:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800691:	8b 45 0c             	mov    0xc(%ebp),%eax
  800694:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800698:	8b 45 08             	mov    0x8(%ebp),%eax
  80069b:	89 44 24 08          	mov    %eax,0x8(%esp)
  80069f:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  8006a5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8006a9:	c7 04 24 ef 06 80 00 	movl   $0x8006ef,(%esp)
  8006b0:	e8 d8 01 00 00       	call   80088d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8006b5:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8006bb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8006bf:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8006c5:	89 04 24             	mov    %eax,(%esp)
  8006c8:	e8 d3 0a 00 00       	call   8011a0 <sys_cputs>

	return b.cnt;
}
  8006cd:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8006d3:	c9                   	leave  
  8006d4:	c3                   	ret    

008006d5 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8006d5:	55                   	push   %ebp
  8006d6:	89 e5                	mov    %esp,%ebp
  8006d8:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  8006db:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  8006de:	89 44 24 04          	mov    %eax,0x4(%esp)
  8006e2:	8b 45 08             	mov    0x8(%ebp),%eax
  8006e5:	89 04 24             	mov    %eax,(%esp)
  8006e8:	e8 87 ff ff ff       	call   800674 <vcprintf>
	va_end(ap);

	return cnt;
}
  8006ed:	c9                   	leave  
  8006ee:	c3                   	ret    

008006ef <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8006ef:	55                   	push   %ebp
  8006f0:	89 e5                	mov    %esp,%ebp
  8006f2:	53                   	push   %ebx
  8006f3:	83 ec 14             	sub    $0x14,%esp
  8006f6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8006f9:	8b 03                	mov    (%ebx),%eax
  8006fb:	8b 55 08             	mov    0x8(%ebp),%edx
  8006fe:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  800702:	83 c0 01             	add    $0x1,%eax
  800705:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800707:	3d ff 00 00 00       	cmp    $0xff,%eax
  80070c:	75 19                	jne    800727 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80070e:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800715:	00 
  800716:	8d 43 08             	lea    0x8(%ebx),%eax
  800719:	89 04 24             	mov    %eax,(%esp)
  80071c:	e8 7f 0a 00 00       	call   8011a0 <sys_cputs>
		b->idx = 0;
  800721:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800727:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80072b:	83 c4 14             	add    $0x14,%esp
  80072e:	5b                   	pop    %ebx
  80072f:	5d                   	pop    %ebp
  800730:	c3                   	ret    
	...

00800740 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800740:	55                   	push   %ebp
  800741:	89 e5                	mov    %esp,%ebp
  800743:	57                   	push   %edi
  800744:	56                   	push   %esi
  800745:	53                   	push   %ebx
  800746:	83 ec 4c             	sub    $0x4c,%esp
  800749:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80074c:	89 d6                	mov    %edx,%esi
  80074e:	8b 45 08             	mov    0x8(%ebp),%eax
  800751:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800754:	8b 55 0c             	mov    0xc(%ebp),%edx
  800757:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80075a:	8b 45 10             	mov    0x10(%ebp),%eax
  80075d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800760:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800763:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800766:	b9 00 00 00 00       	mov    $0x0,%ecx
  80076b:	39 d1                	cmp    %edx,%ecx
  80076d:	72 15                	jb     800784 <printnum+0x44>
  80076f:	77 07                	ja     800778 <printnum+0x38>
  800771:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800774:	39 d0                	cmp    %edx,%eax
  800776:	76 0c                	jbe    800784 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800778:	83 eb 01             	sub    $0x1,%ebx
  80077b:	85 db                	test   %ebx,%ebx
  80077d:	8d 76 00             	lea    0x0(%esi),%esi
  800780:	7f 61                	jg     8007e3 <printnum+0xa3>
  800782:	eb 70                	jmp    8007f4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800784:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800788:	83 eb 01             	sub    $0x1,%ebx
  80078b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80078f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800793:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800797:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80079b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80079e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  8007a1:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8007a4:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8007a8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8007af:	00 
  8007b0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8007b3:	89 04 24             	mov    %eax,(%esp)
  8007b6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8007b9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8007bd:	e8 8e 2c 00 00       	call   803450 <__udivdi3>
  8007c2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8007c5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8007c8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8007cc:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8007d0:	89 04 24             	mov    %eax,(%esp)
  8007d3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8007d7:	89 f2                	mov    %esi,%edx
  8007d9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8007dc:	e8 5f ff ff ff       	call   800740 <printnum>
  8007e1:	eb 11                	jmp    8007f4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  8007e3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007e7:	89 3c 24             	mov    %edi,(%esp)
  8007ea:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8007ed:	83 eb 01             	sub    $0x1,%ebx
  8007f0:	85 db                	test   %ebx,%ebx
  8007f2:	7f ef                	jg     8007e3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8007f4:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007f8:	8b 74 24 04          	mov    0x4(%esp),%esi
  8007fc:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8007ff:	89 44 24 08          	mov    %eax,0x8(%esp)
  800803:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80080a:	00 
  80080b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80080e:	89 14 24             	mov    %edx,(%esp)
  800811:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800814:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800818:	e8 63 2d 00 00       	call   803580 <__umoddi3>
  80081d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800821:	0f be 80 86 38 80 00 	movsbl 0x803886(%eax),%eax
  800828:	89 04 24             	mov    %eax,(%esp)
  80082b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80082e:	83 c4 4c             	add    $0x4c,%esp
  800831:	5b                   	pop    %ebx
  800832:	5e                   	pop    %esi
  800833:	5f                   	pop    %edi
  800834:	5d                   	pop    %ebp
  800835:	c3                   	ret    

00800836 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800836:	55                   	push   %ebp
  800837:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800839:	83 fa 01             	cmp    $0x1,%edx
  80083c:	7e 0e                	jle    80084c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80083e:	8b 10                	mov    (%eax),%edx
  800840:	8d 4a 08             	lea    0x8(%edx),%ecx
  800843:	89 08                	mov    %ecx,(%eax)
  800845:	8b 02                	mov    (%edx),%eax
  800847:	8b 52 04             	mov    0x4(%edx),%edx
  80084a:	eb 22                	jmp    80086e <getuint+0x38>
	else if (lflag)
  80084c:	85 d2                	test   %edx,%edx
  80084e:	74 10                	je     800860 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800850:	8b 10                	mov    (%eax),%edx
  800852:	8d 4a 04             	lea    0x4(%edx),%ecx
  800855:	89 08                	mov    %ecx,(%eax)
  800857:	8b 02                	mov    (%edx),%eax
  800859:	ba 00 00 00 00       	mov    $0x0,%edx
  80085e:	eb 0e                	jmp    80086e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800860:	8b 10                	mov    (%eax),%edx
  800862:	8d 4a 04             	lea    0x4(%edx),%ecx
  800865:	89 08                	mov    %ecx,(%eax)
  800867:	8b 02                	mov    (%edx),%eax
  800869:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80086e:	5d                   	pop    %ebp
  80086f:	c3                   	ret    

00800870 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800870:	55                   	push   %ebp
  800871:	89 e5                	mov    %esp,%ebp
  800873:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800876:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80087a:	8b 10                	mov    (%eax),%edx
  80087c:	3b 50 04             	cmp    0x4(%eax),%edx
  80087f:	73 0a                	jae    80088b <sprintputch+0x1b>
		*b->buf++ = ch;
  800881:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800884:	88 0a                	mov    %cl,(%edx)
  800886:	83 c2 01             	add    $0x1,%edx
  800889:	89 10                	mov    %edx,(%eax)
}
  80088b:	5d                   	pop    %ebp
  80088c:	c3                   	ret    

0080088d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80088d:	55                   	push   %ebp
  80088e:	89 e5                	mov    %esp,%ebp
  800890:	57                   	push   %edi
  800891:	56                   	push   %esi
  800892:	53                   	push   %ebx
  800893:	83 ec 5c             	sub    $0x5c,%esp
  800896:	8b 7d 08             	mov    0x8(%ebp),%edi
  800899:	8b 75 0c             	mov    0xc(%ebp),%esi
  80089c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80089f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  8008a6:	eb 11                	jmp    8008b9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  8008a8:	85 c0                	test   %eax,%eax
  8008aa:	0f 84 f9 03 00 00    	je     800ca9 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8008b0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008b4:	89 04 24             	mov    %eax,(%esp)
  8008b7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8008b9:	0f b6 03             	movzbl (%ebx),%eax
  8008bc:	83 c3 01             	add    $0x1,%ebx
  8008bf:	83 f8 25             	cmp    $0x25,%eax
  8008c2:	75 e4                	jne    8008a8 <vprintfmt+0x1b>
  8008c4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8008c8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8008cf:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8008d6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8008dd:	b9 00 00 00 00       	mov    $0x0,%ecx
  8008e2:	eb 06                	jmp    8008ea <vprintfmt+0x5d>
  8008e4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  8008e8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  8008ea:	0f b6 13             	movzbl (%ebx),%edx
  8008ed:	0f b6 c2             	movzbl %dl,%eax
  8008f0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8008f3:	8d 43 01             	lea    0x1(%ebx),%eax
  8008f6:	83 ea 23             	sub    $0x23,%edx
  8008f9:	80 fa 55             	cmp    $0x55,%dl
  8008fc:	0f 87 8a 03 00 00    	ja     800c8c <vprintfmt+0x3ff>
  800902:	0f b6 d2             	movzbl %dl,%edx
  800905:	ff 24 95 c0 39 80 00 	jmp    *0x8039c0(,%edx,4)
  80090c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800910:	eb d6                	jmp    8008e8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800912:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800915:	83 ea 30             	sub    $0x30,%edx
  800918:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80091b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80091e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800921:	83 fb 09             	cmp    $0x9,%ebx
  800924:	77 54                	ja     80097a <vprintfmt+0xed>
  800926:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800929:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80092c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80092f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800932:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800936:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800939:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80093c:	83 fb 09             	cmp    $0x9,%ebx
  80093f:	76 eb                	jbe    80092c <vprintfmt+0x9f>
  800941:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800944:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800947:	eb 31                	jmp    80097a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800949:	8b 55 14             	mov    0x14(%ebp),%edx
  80094c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80094f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800952:	8b 12                	mov    (%edx),%edx
  800954:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800957:	eb 21                	jmp    80097a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800959:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80095d:	ba 00 00 00 00       	mov    $0x0,%edx
  800962:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800966:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800969:	e9 7a ff ff ff       	jmp    8008e8 <vprintfmt+0x5b>
  80096e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800975:	e9 6e ff ff ff       	jmp    8008e8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80097a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80097e:	0f 89 64 ff ff ff    	jns    8008e8 <vprintfmt+0x5b>
  800984:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800987:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80098a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80098d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800990:	e9 53 ff ff ff       	jmp    8008e8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800995:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800998:	e9 4b ff ff ff       	jmp    8008e8 <vprintfmt+0x5b>
  80099d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  8009a0:	8b 45 14             	mov    0x14(%ebp),%eax
  8009a3:	8d 50 04             	lea    0x4(%eax),%edx
  8009a6:	89 55 14             	mov    %edx,0x14(%ebp)
  8009a9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009ad:	8b 00                	mov    (%eax),%eax
  8009af:	89 04 24             	mov    %eax,(%esp)
  8009b2:	ff d7                	call   *%edi
  8009b4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8009b7:	e9 fd fe ff ff       	jmp    8008b9 <vprintfmt+0x2c>
  8009bc:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8009bf:	8b 45 14             	mov    0x14(%ebp),%eax
  8009c2:	8d 50 04             	lea    0x4(%eax),%edx
  8009c5:	89 55 14             	mov    %edx,0x14(%ebp)
  8009c8:	8b 00                	mov    (%eax),%eax
  8009ca:	89 c2                	mov    %eax,%edx
  8009cc:	c1 fa 1f             	sar    $0x1f,%edx
  8009cf:	31 d0                	xor    %edx,%eax
  8009d1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8009d3:	83 f8 12             	cmp    $0x12,%eax
  8009d6:	7f 0b                	jg     8009e3 <vprintfmt+0x156>
  8009d8:	8b 14 85 20 3b 80 00 	mov    0x803b20(,%eax,4),%edx
  8009df:	85 d2                	test   %edx,%edx
  8009e1:	75 20                	jne    800a03 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  8009e3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8009e7:	c7 44 24 08 97 38 80 	movl   $0x803897,0x8(%esp)
  8009ee:	00 
  8009ef:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009f3:	89 3c 24             	mov    %edi,(%esp)
  8009f6:	e8 36 03 00 00       	call   800d31 <printfmt>
  8009fb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8009fe:	e9 b6 fe ff ff       	jmp    8008b9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800a03:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800a07:	c7 44 24 08 34 3e 80 	movl   $0x803e34,0x8(%esp)
  800a0e:	00 
  800a0f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a13:	89 3c 24             	mov    %edi,(%esp)
  800a16:	e8 16 03 00 00       	call   800d31 <printfmt>
  800a1b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  800a1e:	e9 96 fe ff ff       	jmp    8008b9 <vprintfmt+0x2c>
  800a23:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800a26:	89 c3                	mov    %eax,%ebx
  800a28:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800a2b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800a2e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800a31:	8b 45 14             	mov    0x14(%ebp),%eax
  800a34:	8d 50 04             	lea    0x4(%eax),%edx
  800a37:	89 55 14             	mov    %edx,0x14(%ebp)
  800a3a:	8b 00                	mov    (%eax),%eax
  800a3c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800a3f:	85 c0                	test   %eax,%eax
  800a41:	b8 a0 38 80 00       	mov    $0x8038a0,%eax
  800a46:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  800a4a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  800a4d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800a51:	7e 06                	jle    800a59 <vprintfmt+0x1cc>
  800a53:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800a57:	75 13                	jne    800a6c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800a59:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800a5c:	0f be 02             	movsbl (%edx),%eax
  800a5f:	85 c0                	test   %eax,%eax
  800a61:	0f 85 9b 00 00 00    	jne    800b02 <vprintfmt+0x275>
  800a67:	e9 88 00 00 00       	jmp    800af4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  800a6c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800a70:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800a73:	89 0c 24             	mov    %ecx,(%esp)
  800a76:	e8 00 03 00 00       	call   800d7b <strnlen>
  800a7b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  800a7e:	29 c2                	sub    %eax,%edx
  800a80:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800a83:	85 d2                	test   %edx,%edx
  800a85:	7e d2                	jle    800a59 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800a87:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  800a8b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  800a8e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800a91:	89 d3                	mov    %edx,%ebx
  800a93:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a97:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  800a9a:	89 04 24             	mov    %eax,(%esp)
  800a9d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  800a9f:	83 eb 01             	sub    $0x1,%ebx
  800aa2:	85 db                	test   %ebx,%ebx
  800aa4:	7f ed                	jg     800a93 <vprintfmt+0x206>
  800aa6:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800aa9:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800ab0:	eb a7                	jmp    800a59 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800ab2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800ab6:	74 1a                	je     800ad2 <vprintfmt+0x245>
  800ab8:	8d 50 e0             	lea    -0x20(%eax),%edx
  800abb:	83 fa 5e             	cmp    $0x5e,%edx
  800abe:	76 12                	jbe    800ad2 <vprintfmt+0x245>
					putch('?', putdat);
  800ac0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800ac4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  800acb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800ace:	66 90                	xchg   %ax,%ax
  800ad0:	eb 0a                	jmp    800adc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800ad2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800ad6:	89 04 24             	mov    %eax,(%esp)
  800ad9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800adc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800ae0:	0f be 03             	movsbl (%ebx),%eax
  800ae3:	85 c0                	test   %eax,%eax
  800ae5:	74 05                	je     800aec <vprintfmt+0x25f>
  800ae7:	83 c3 01             	add    $0x1,%ebx
  800aea:	eb 29                	jmp    800b15 <vprintfmt+0x288>
  800aec:	89 fe                	mov    %edi,%esi
  800aee:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800af1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800af4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800af8:	7f 2e                	jg     800b28 <vprintfmt+0x29b>
  800afa:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  800afd:	e9 b7 fd ff ff       	jmp    8008b9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800b02:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800b05:	83 c2 01             	add    $0x1,%edx
  800b08:	89 7d e0             	mov    %edi,-0x20(%ebp)
  800b0b:	89 f7                	mov    %esi,%edi
  800b0d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800b10:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800b13:	89 d3                	mov    %edx,%ebx
  800b15:	85 f6                	test   %esi,%esi
  800b17:	78 99                	js     800ab2 <vprintfmt+0x225>
  800b19:	83 ee 01             	sub    $0x1,%esi
  800b1c:	79 94                	jns    800ab2 <vprintfmt+0x225>
  800b1e:	89 fe                	mov    %edi,%esi
  800b20:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800b23:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800b26:	eb cc                	jmp    800af4 <vprintfmt+0x267>
  800b28:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  800b2b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  800b2e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800b32:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800b39:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800b3b:	83 eb 01             	sub    $0x1,%ebx
  800b3e:	85 db                	test   %ebx,%ebx
  800b40:	7f ec                	jg     800b2e <vprintfmt+0x2a1>
  800b42:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800b45:	e9 6f fd ff ff       	jmp    8008b9 <vprintfmt+0x2c>
  800b4a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  800b4d:	83 f9 01             	cmp    $0x1,%ecx
  800b50:	7e 16                	jle    800b68 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800b52:	8b 45 14             	mov    0x14(%ebp),%eax
  800b55:	8d 50 08             	lea    0x8(%eax),%edx
  800b58:	89 55 14             	mov    %edx,0x14(%ebp)
  800b5b:	8b 10                	mov    (%eax),%edx
  800b5d:	8b 48 04             	mov    0x4(%eax),%ecx
  800b60:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800b63:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800b66:	eb 32                	jmp    800b9a <vprintfmt+0x30d>
	else if (lflag)
  800b68:	85 c9                	test   %ecx,%ecx
  800b6a:	74 18                	je     800b84 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  800b6c:	8b 45 14             	mov    0x14(%ebp),%eax
  800b6f:	8d 50 04             	lea    0x4(%eax),%edx
  800b72:	89 55 14             	mov    %edx,0x14(%ebp)
  800b75:	8b 00                	mov    (%eax),%eax
  800b77:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800b7a:	89 c1                	mov    %eax,%ecx
  800b7c:	c1 f9 1f             	sar    $0x1f,%ecx
  800b7f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800b82:	eb 16                	jmp    800b9a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800b84:	8b 45 14             	mov    0x14(%ebp),%eax
  800b87:	8d 50 04             	lea    0x4(%eax),%edx
  800b8a:	89 55 14             	mov    %edx,0x14(%ebp)
  800b8d:	8b 00                	mov    (%eax),%eax
  800b8f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800b92:	89 c2                	mov    %eax,%edx
  800b94:	c1 fa 1f             	sar    $0x1f,%edx
  800b97:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  800b9a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  800b9d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800ba0:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800ba5:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800ba9:	0f 89 9b 00 00 00    	jns    800c4a <vprintfmt+0x3bd>
				putch('-', putdat);
  800baf:	89 74 24 04          	mov    %esi,0x4(%esp)
  800bb3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  800bba:	ff d7                	call   *%edi
				num = -(long long) num;
  800bbc:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  800bbf:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800bc2:	f7 d9                	neg    %ecx
  800bc4:	83 d3 00             	adc    $0x0,%ebx
  800bc7:	f7 db                	neg    %ebx
  800bc9:	b8 0a 00 00 00       	mov    $0xa,%eax
  800bce:	eb 7a                	jmp    800c4a <vprintfmt+0x3bd>
  800bd0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800bd3:	89 ca                	mov    %ecx,%edx
  800bd5:	8d 45 14             	lea    0x14(%ebp),%eax
  800bd8:	e8 59 fc ff ff       	call   800836 <getuint>
  800bdd:	89 c1                	mov    %eax,%ecx
  800bdf:	89 d3                	mov    %edx,%ebx
  800be1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800be6:	eb 62                	jmp    800c4a <vprintfmt+0x3bd>
  800be8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  800beb:	89 ca                	mov    %ecx,%edx
  800bed:	8d 45 14             	lea    0x14(%ebp),%eax
  800bf0:	e8 41 fc ff ff       	call   800836 <getuint>
  800bf5:	89 c1                	mov    %eax,%ecx
  800bf7:	89 d3                	mov    %edx,%ebx
  800bf9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  800bfe:	eb 4a                	jmp    800c4a <vprintfmt+0x3bd>
  800c00:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800c03:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c07:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  800c0e:	ff d7                	call   *%edi
			putch('x', putdat);
  800c10:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c14:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  800c1b:	ff d7                	call   *%edi
			num = (unsigned long long)
  800c1d:	8b 45 14             	mov    0x14(%ebp),%eax
  800c20:	8d 50 04             	lea    0x4(%eax),%edx
  800c23:	89 55 14             	mov    %edx,0x14(%ebp)
  800c26:	8b 08                	mov    (%eax),%ecx
  800c28:	bb 00 00 00 00       	mov    $0x0,%ebx
  800c2d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800c32:	eb 16                	jmp    800c4a <vprintfmt+0x3bd>
  800c34:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800c37:	89 ca                	mov    %ecx,%edx
  800c39:	8d 45 14             	lea    0x14(%ebp),%eax
  800c3c:	e8 f5 fb ff ff       	call   800836 <getuint>
  800c41:	89 c1                	mov    %eax,%ecx
  800c43:	89 d3                	mov    %edx,%ebx
  800c45:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  800c4a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  800c4e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800c52:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800c55:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800c59:	89 44 24 08          	mov    %eax,0x8(%esp)
  800c5d:	89 0c 24             	mov    %ecx,(%esp)
  800c60:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800c64:	89 f2                	mov    %esi,%edx
  800c66:	89 f8                	mov    %edi,%eax
  800c68:	e8 d3 fa ff ff       	call   800740 <printnum>
  800c6d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800c70:	e9 44 fc ff ff       	jmp    8008b9 <vprintfmt+0x2c>
  800c75:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800c78:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  800c7b:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c7f:	89 14 24             	mov    %edx,(%esp)
  800c82:	ff d7                	call   *%edi
  800c84:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800c87:	e9 2d fc ff ff       	jmp    8008b9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  800c8c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c90:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800c97:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800c99:	8d 43 ff             	lea    -0x1(%ebx),%eax
  800c9c:	80 38 25             	cmpb   $0x25,(%eax)
  800c9f:	0f 84 14 fc ff ff    	je     8008b9 <vprintfmt+0x2c>
  800ca5:	89 c3                	mov    %eax,%ebx
  800ca7:	eb f0                	jmp    800c99 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800ca9:	83 c4 5c             	add    $0x5c,%esp
  800cac:	5b                   	pop    %ebx
  800cad:	5e                   	pop    %esi
  800cae:	5f                   	pop    %edi
  800caf:	5d                   	pop    %ebp
  800cb0:	c3                   	ret    

00800cb1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800cb1:	55                   	push   %ebp
  800cb2:	89 e5                	mov    %esp,%ebp
  800cb4:	83 ec 28             	sub    $0x28,%esp
  800cb7:	8b 45 08             	mov    0x8(%ebp),%eax
  800cba:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  800cbd:	85 c0                	test   %eax,%eax
  800cbf:	74 04                	je     800cc5 <vsnprintf+0x14>
  800cc1:	85 d2                	test   %edx,%edx
  800cc3:	7f 07                	jg     800ccc <vsnprintf+0x1b>
  800cc5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800cca:	eb 3b                	jmp    800d07 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  800ccc:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800ccf:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800cd3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800cd6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800cdd:	8b 45 14             	mov    0x14(%ebp),%eax
  800ce0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800ce4:	8b 45 10             	mov    0x10(%ebp),%eax
  800ce7:	89 44 24 08          	mov    %eax,0x8(%esp)
  800ceb:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800cee:	89 44 24 04          	mov    %eax,0x4(%esp)
  800cf2:	c7 04 24 70 08 80 00 	movl   $0x800870,(%esp)
  800cf9:	e8 8f fb ff ff       	call   80088d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800cfe:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800d01:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800d04:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800d07:	c9                   	leave  
  800d08:	c3                   	ret    

00800d09 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800d09:	55                   	push   %ebp
  800d0a:	89 e5                	mov    %esp,%ebp
  800d0c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800d0f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800d12:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800d16:	8b 45 10             	mov    0x10(%ebp),%eax
  800d19:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d1d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d20:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d24:	8b 45 08             	mov    0x8(%ebp),%eax
  800d27:	89 04 24             	mov    %eax,(%esp)
  800d2a:	e8 82 ff ff ff       	call   800cb1 <vsnprintf>
	va_end(ap);

	return rc;
}
  800d2f:	c9                   	leave  
  800d30:	c3                   	ret    

00800d31 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800d31:	55                   	push   %ebp
  800d32:	89 e5                	mov    %esp,%ebp
  800d34:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800d37:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800d3a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800d3e:	8b 45 10             	mov    0x10(%ebp),%eax
  800d41:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d45:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d48:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d4c:	8b 45 08             	mov    0x8(%ebp),%eax
  800d4f:	89 04 24             	mov    %eax,(%esp)
  800d52:	e8 36 fb ff ff       	call   80088d <vprintfmt>
	va_end(ap);
}
  800d57:	c9                   	leave  
  800d58:	c3                   	ret    
  800d59:	00 00                	add    %al,(%eax)
  800d5b:	00 00                	add    %al,(%eax)
  800d5d:	00 00                	add    %al,(%eax)
	...

00800d60 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800d60:	55                   	push   %ebp
  800d61:	89 e5                	mov    %esp,%ebp
  800d63:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800d66:	b8 00 00 00 00       	mov    $0x0,%eax
  800d6b:	80 3a 00             	cmpb   $0x0,(%edx)
  800d6e:	74 09                	je     800d79 <strlen+0x19>
		n++;
  800d70:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800d73:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800d77:	75 f7                	jne    800d70 <strlen+0x10>
		n++;
	return n;
}
  800d79:	5d                   	pop    %ebp
  800d7a:	c3                   	ret    

00800d7b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800d7b:	55                   	push   %ebp
  800d7c:	89 e5                	mov    %esp,%ebp
  800d7e:	53                   	push   %ebx
  800d7f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800d82:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800d85:	85 c9                	test   %ecx,%ecx
  800d87:	74 19                	je     800da2 <strnlen+0x27>
  800d89:	80 3b 00             	cmpb   $0x0,(%ebx)
  800d8c:	74 14                	je     800da2 <strnlen+0x27>
  800d8e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800d93:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800d96:	39 c8                	cmp    %ecx,%eax
  800d98:	74 0d                	je     800da7 <strnlen+0x2c>
  800d9a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800d9e:	75 f3                	jne    800d93 <strnlen+0x18>
  800da0:	eb 05                	jmp    800da7 <strnlen+0x2c>
  800da2:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800da7:	5b                   	pop    %ebx
  800da8:	5d                   	pop    %ebp
  800da9:	c3                   	ret    

00800daa <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800daa:	55                   	push   %ebp
  800dab:	89 e5                	mov    %esp,%ebp
  800dad:	53                   	push   %ebx
  800dae:	8b 45 08             	mov    0x8(%ebp),%eax
  800db1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800db4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800db9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800dbd:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800dc0:	83 c2 01             	add    $0x1,%edx
  800dc3:	84 c9                	test   %cl,%cl
  800dc5:	75 f2                	jne    800db9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800dc7:	5b                   	pop    %ebx
  800dc8:	5d                   	pop    %ebp
  800dc9:	c3                   	ret    

00800dca <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800dca:	55                   	push   %ebp
  800dcb:	89 e5                	mov    %esp,%ebp
  800dcd:	56                   	push   %esi
  800dce:	53                   	push   %ebx
  800dcf:	8b 45 08             	mov    0x8(%ebp),%eax
  800dd2:	8b 55 0c             	mov    0xc(%ebp),%edx
  800dd5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800dd8:	85 f6                	test   %esi,%esi
  800dda:	74 18                	je     800df4 <strncpy+0x2a>
  800ddc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800de1:	0f b6 1a             	movzbl (%edx),%ebx
  800de4:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800de7:	80 3a 01             	cmpb   $0x1,(%edx)
  800dea:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800ded:	83 c1 01             	add    $0x1,%ecx
  800df0:	39 ce                	cmp    %ecx,%esi
  800df2:	77 ed                	ja     800de1 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800df4:	5b                   	pop    %ebx
  800df5:	5e                   	pop    %esi
  800df6:	5d                   	pop    %ebp
  800df7:	c3                   	ret    

00800df8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800df8:	55                   	push   %ebp
  800df9:	89 e5                	mov    %esp,%ebp
  800dfb:	56                   	push   %esi
  800dfc:	53                   	push   %ebx
  800dfd:	8b 75 08             	mov    0x8(%ebp),%esi
  800e00:	8b 55 0c             	mov    0xc(%ebp),%edx
  800e03:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800e06:	89 f0                	mov    %esi,%eax
  800e08:	85 c9                	test   %ecx,%ecx
  800e0a:	74 27                	je     800e33 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800e0c:	83 e9 01             	sub    $0x1,%ecx
  800e0f:	74 1d                	je     800e2e <strlcpy+0x36>
  800e11:	0f b6 1a             	movzbl (%edx),%ebx
  800e14:	84 db                	test   %bl,%bl
  800e16:	74 16                	je     800e2e <strlcpy+0x36>
			*dst++ = *src++;
  800e18:	88 18                	mov    %bl,(%eax)
  800e1a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800e1d:	83 e9 01             	sub    $0x1,%ecx
  800e20:	74 0e                	je     800e30 <strlcpy+0x38>
			*dst++ = *src++;
  800e22:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800e25:	0f b6 1a             	movzbl (%edx),%ebx
  800e28:	84 db                	test   %bl,%bl
  800e2a:	75 ec                	jne    800e18 <strlcpy+0x20>
  800e2c:	eb 02                	jmp    800e30 <strlcpy+0x38>
  800e2e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800e30:	c6 00 00             	movb   $0x0,(%eax)
  800e33:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800e35:	5b                   	pop    %ebx
  800e36:	5e                   	pop    %esi
  800e37:	5d                   	pop    %ebp
  800e38:	c3                   	ret    

00800e39 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800e39:	55                   	push   %ebp
  800e3a:	89 e5                	mov    %esp,%ebp
  800e3c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800e3f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800e42:	0f b6 01             	movzbl (%ecx),%eax
  800e45:	84 c0                	test   %al,%al
  800e47:	74 15                	je     800e5e <strcmp+0x25>
  800e49:	3a 02                	cmp    (%edx),%al
  800e4b:	75 11                	jne    800e5e <strcmp+0x25>
		p++, q++;
  800e4d:	83 c1 01             	add    $0x1,%ecx
  800e50:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800e53:	0f b6 01             	movzbl (%ecx),%eax
  800e56:	84 c0                	test   %al,%al
  800e58:	74 04                	je     800e5e <strcmp+0x25>
  800e5a:	3a 02                	cmp    (%edx),%al
  800e5c:	74 ef                	je     800e4d <strcmp+0x14>
  800e5e:	0f b6 c0             	movzbl %al,%eax
  800e61:	0f b6 12             	movzbl (%edx),%edx
  800e64:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800e66:	5d                   	pop    %ebp
  800e67:	c3                   	ret    

00800e68 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800e68:	55                   	push   %ebp
  800e69:	89 e5                	mov    %esp,%ebp
  800e6b:	53                   	push   %ebx
  800e6c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e6f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e72:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800e75:	85 c0                	test   %eax,%eax
  800e77:	74 23                	je     800e9c <strncmp+0x34>
  800e79:	0f b6 1a             	movzbl (%edx),%ebx
  800e7c:	84 db                	test   %bl,%bl
  800e7e:	74 24                	je     800ea4 <strncmp+0x3c>
  800e80:	3a 19                	cmp    (%ecx),%bl
  800e82:	75 20                	jne    800ea4 <strncmp+0x3c>
  800e84:	83 e8 01             	sub    $0x1,%eax
  800e87:	74 13                	je     800e9c <strncmp+0x34>
		n--, p++, q++;
  800e89:	83 c2 01             	add    $0x1,%edx
  800e8c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800e8f:	0f b6 1a             	movzbl (%edx),%ebx
  800e92:	84 db                	test   %bl,%bl
  800e94:	74 0e                	je     800ea4 <strncmp+0x3c>
  800e96:	3a 19                	cmp    (%ecx),%bl
  800e98:	74 ea                	je     800e84 <strncmp+0x1c>
  800e9a:	eb 08                	jmp    800ea4 <strncmp+0x3c>
  800e9c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800ea1:	5b                   	pop    %ebx
  800ea2:	5d                   	pop    %ebp
  800ea3:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800ea4:	0f b6 02             	movzbl (%edx),%eax
  800ea7:	0f b6 11             	movzbl (%ecx),%edx
  800eaa:	29 d0                	sub    %edx,%eax
  800eac:	eb f3                	jmp    800ea1 <strncmp+0x39>

00800eae <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800eae:	55                   	push   %ebp
  800eaf:	89 e5                	mov    %esp,%ebp
  800eb1:	8b 45 08             	mov    0x8(%ebp),%eax
  800eb4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800eb8:	0f b6 10             	movzbl (%eax),%edx
  800ebb:	84 d2                	test   %dl,%dl
  800ebd:	74 15                	je     800ed4 <strchr+0x26>
		if (*s == c)
  800ebf:	38 ca                	cmp    %cl,%dl
  800ec1:	75 07                	jne    800eca <strchr+0x1c>
  800ec3:	eb 14                	jmp    800ed9 <strchr+0x2b>
  800ec5:	38 ca                	cmp    %cl,%dl
  800ec7:	90                   	nop
  800ec8:	74 0f                	je     800ed9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800eca:	83 c0 01             	add    $0x1,%eax
  800ecd:	0f b6 10             	movzbl (%eax),%edx
  800ed0:	84 d2                	test   %dl,%dl
  800ed2:	75 f1                	jne    800ec5 <strchr+0x17>
  800ed4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800ed9:	5d                   	pop    %ebp
  800eda:	c3                   	ret    

00800edb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800edb:	55                   	push   %ebp
  800edc:	89 e5                	mov    %esp,%ebp
  800ede:	8b 45 08             	mov    0x8(%ebp),%eax
  800ee1:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800ee5:	0f b6 10             	movzbl (%eax),%edx
  800ee8:	84 d2                	test   %dl,%dl
  800eea:	74 18                	je     800f04 <strfind+0x29>
		if (*s == c)
  800eec:	38 ca                	cmp    %cl,%dl
  800eee:	75 0a                	jne    800efa <strfind+0x1f>
  800ef0:	eb 12                	jmp    800f04 <strfind+0x29>
  800ef2:	38 ca                	cmp    %cl,%dl
  800ef4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800ef8:	74 0a                	je     800f04 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800efa:	83 c0 01             	add    $0x1,%eax
  800efd:	0f b6 10             	movzbl (%eax),%edx
  800f00:	84 d2                	test   %dl,%dl
  800f02:	75 ee                	jne    800ef2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800f04:	5d                   	pop    %ebp
  800f05:	c3                   	ret    

00800f06 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800f06:	55                   	push   %ebp
  800f07:	89 e5                	mov    %esp,%ebp
  800f09:	83 ec 0c             	sub    $0xc,%esp
  800f0c:	89 1c 24             	mov    %ebx,(%esp)
  800f0f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f13:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800f17:	8b 7d 08             	mov    0x8(%ebp),%edi
  800f1a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800f1d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800f20:	85 c9                	test   %ecx,%ecx
  800f22:	74 30                	je     800f54 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800f24:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800f2a:	75 25                	jne    800f51 <memset+0x4b>
  800f2c:	f6 c1 03             	test   $0x3,%cl
  800f2f:	75 20                	jne    800f51 <memset+0x4b>
		c &= 0xFF;
  800f31:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800f34:	89 d3                	mov    %edx,%ebx
  800f36:	c1 e3 08             	shl    $0x8,%ebx
  800f39:	89 d6                	mov    %edx,%esi
  800f3b:	c1 e6 18             	shl    $0x18,%esi
  800f3e:	89 d0                	mov    %edx,%eax
  800f40:	c1 e0 10             	shl    $0x10,%eax
  800f43:	09 f0                	or     %esi,%eax
  800f45:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800f47:	09 d8                	or     %ebx,%eax
  800f49:	c1 e9 02             	shr    $0x2,%ecx
  800f4c:	fc                   	cld    
  800f4d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800f4f:	eb 03                	jmp    800f54 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800f51:	fc                   	cld    
  800f52:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800f54:	89 f8                	mov    %edi,%eax
  800f56:	8b 1c 24             	mov    (%esp),%ebx
  800f59:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f5d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f61:	89 ec                	mov    %ebp,%esp
  800f63:	5d                   	pop    %ebp
  800f64:	c3                   	ret    

00800f65 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800f65:	55                   	push   %ebp
  800f66:	89 e5                	mov    %esp,%ebp
  800f68:	83 ec 08             	sub    $0x8,%esp
  800f6b:	89 34 24             	mov    %esi,(%esp)
  800f6e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800f72:	8b 45 08             	mov    0x8(%ebp),%eax
  800f75:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800f78:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800f7b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800f7d:	39 c6                	cmp    %eax,%esi
  800f7f:	73 35                	jae    800fb6 <memmove+0x51>
  800f81:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800f84:	39 d0                	cmp    %edx,%eax
  800f86:	73 2e                	jae    800fb6 <memmove+0x51>
		s += n;
		d += n;
  800f88:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800f8a:	f6 c2 03             	test   $0x3,%dl
  800f8d:	75 1b                	jne    800faa <memmove+0x45>
  800f8f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800f95:	75 13                	jne    800faa <memmove+0x45>
  800f97:	f6 c1 03             	test   $0x3,%cl
  800f9a:	75 0e                	jne    800faa <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800f9c:	83 ef 04             	sub    $0x4,%edi
  800f9f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800fa2:	c1 e9 02             	shr    $0x2,%ecx
  800fa5:	fd                   	std    
  800fa6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800fa8:	eb 09                	jmp    800fb3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800faa:	83 ef 01             	sub    $0x1,%edi
  800fad:	8d 72 ff             	lea    -0x1(%edx),%esi
  800fb0:	fd                   	std    
  800fb1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800fb3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800fb4:	eb 20                	jmp    800fd6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800fb6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800fbc:	75 15                	jne    800fd3 <memmove+0x6e>
  800fbe:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800fc4:	75 0d                	jne    800fd3 <memmove+0x6e>
  800fc6:	f6 c1 03             	test   $0x3,%cl
  800fc9:	75 08                	jne    800fd3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800fcb:	c1 e9 02             	shr    $0x2,%ecx
  800fce:	fc                   	cld    
  800fcf:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800fd1:	eb 03                	jmp    800fd6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800fd3:	fc                   	cld    
  800fd4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800fd6:	8b 34 24             	mov    (%esp),%esi
  800fd9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800fdd:	89 ec                	mov    %ebp,%esp
  800fdf:	5d                   	pop    %ebp
  800fe0:	c3                   	ret    

00800fe1 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800fe1:	55                   	push   %ebp
  800fe2:	89 e5                	mov    %esp,%ebp
  800fe4:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800fe7:	8b 45 10             	mov    0x10(%ebp),%eax
  800fea:	89 44 24 08          	mov    %eax,0x8(%esp)
  800fee:	8b 45 0c             	mov    0xc(%ebp),%eax
  800ff1:	89 44 24 04          	mov    %eax,0x4(%esp)
  800ff5:	8b 45 08             	mov    0x8(%ebp),%eax
  800ff8:	89 04 24             	mov    %eax,(%esp)
  800ffb:	e8 65 ff ff ff       	call   800f65 <memmove>
}
  801000:	c9                   	leave  
  801001:	c3                   	ret    

00801002 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  801002:	55                   	push   %ebp
  801003:	89 e5                	mov    %esp,%ebp
  801005:	57                   	push   %edi
  801006:	56                   	push   %esi
  801007:	53                   	push   %ebx
  801008:	8b 75 08             	mov    0x8(%ebp),%esi
  80100b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80100e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  801011:	85 c9                	test   %ecx,%ecx
  801013:	74 36                	je     80104b <memcmp+0x49>
		if (*s1 != *s2)
  801015:	0f b6 06             	movzbl (%esi),%eax
  801018:	0f b6 1f             	movzbl (%edi),%ebx
  80101b:	38 d8                	cmp    %bl,%al
  80101d:	74 20                	je     80103f <memcmp+0x3d>
  80101f:	eb 14                	jmp    801035 <memcmp+0x33>
  801021:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  801026:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  80102b:	83 c2 01             	add    $0x1,%edx
  80102e:	83 e9 01             	sub    $0x1,%ecx
  801031:	38 d8                	cmp    %bl,%al
  801033:	74 12                	je     801047 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  801035:	0f b6 c0             	movzbl %al,%eax
  801038:	0f b6 db             	movzbl %bl,%ebx
  80103b:	29 d8                	sub    %ebx,%eax
  80103d:	eb 11                	jmp    801050 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  80103f:	83 e9 01             	sub    $0x1,%ecx
  801042:	ba 00 00 00 00       	mov    $0x0,%edx
  801047:	85 c9                	test   %ecx,%ecx
  801049:	75 d6                	jne    801021 <memcmp+0x1f>
  80104b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  801050:	5b                   	pop    %ebx
  801051:	5e                   	pop    %esi
  801052:	5f                   	pop    %edi
  801053:	5d                   	pop    %ebp
  801054:	c3                   	ret    

00801055 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  801055:	55                   	push   %ebp
  801056:	89 e5                	mov    %esp,%ebp
  801058:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  80105b:	89 c2                	mov    %eax,%edx
  80105d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  801060:	39 d0                	cmp    %edx,%eax
  801062:	73 15                	jae    801079 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  801064:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  801068:	38 08                	cmp    %cl,(%eax)
  80106a:	75 06                	jne    801072 <memfind+0x1d>
  80106c:	eb 0b                	jmp    801079 <memfind+0x24>
  80106e:	38 08                	cmp    %cl,(%eax)
  801070:	74 07                	je     801079 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  801072:	83 c0 01             	add    $0x1,%eax
  801075:	39 c2                	cmp    %eax,%edx
  801077:	77 f5                	ja     80106e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  801079:	5d                   	pop    %ebp
  80107a:	c3                   	ret    

0080107b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  80107b:	55                   	push   %ebp
  80107c:	89 e5                	mov    %esp,%ebp
  80107e:	57                   	push   %edi
  80107f:	56                   	push   %esi
  801080:	53                   	push   %ebx
  801081:	83 ec 04             	sub    $0x4,%esp
  801084:	8b 55 08             	mov    0x8(%ebp),%edx
  801087:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  80108a:	0f b6 02             	movzbl (%edx),%eax
  80108d:	3c 20                	cmp    $0x20,%al
  80108f:	74 04                	je     801095 <strtol+0x1a>
  801091:	3c 09                	cmp    $0x9,%al
  801093:	75 0e                	jne    8010a3 <strtol+0x28>
		s++;
  801095:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  801098:	0f b6 02             	movzbl (%edx),%eax
  80109b:	3c 20                	cmp    $0x20,%al
  80109d:	74 f6                	je     801095 <strtol+0x1a>
  80109f:	3c 09                	cmp    $0x9,%al
  8010a1:	74 f2                	je     801095 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  8010a3:	3c 2b                	cmp    $0x2b,%al
  8010a5:	75 0c                	jne    8010b3 <strtol+0x38>
		s++;
  8010a7:	83 c2 01             	add    $0x1,%edx
  8010aa:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  8010b1:	eb 15                	jmp    8010c8 <strtol+0x4d>
	else if (*s == '-')
  8010b3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  8010ba:	3c 2d                	cmp    $0x2d,%al
  8010bc:	75 0a                	jne    8010c8 <strtol+0x4d>
		s++, neg = 1;
  8010be:	83 c2 01             	add    $0x1,%edx
  8010c1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  8010c8:	85 db                	test   %ebx,%ebx
  8010ca:	0f 94 c0             	sete   %al
  8010cd:	74 05                	je     8010d4 <strtol+0x59>
  8010cf:	83 fb 10             	cmp    $0x10,%ebx
  8010d2:	75 18                	jne    8010ec <strtol+0x71>
  8010d4:	80 3a 30             	cmpb   $0x30,(%edx)
  8010d7:	75 13                	jne    8010ec <strtol+0x71>
  8010d9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  8010dd:	8d 76 00             	lea    0x0(%esi),%esi
  8010e0:	75 0a                	jne    8010ec <strtol+0x71>
		s += 2, base = 16;
  8010e2:	83 c2 02             	add    $0x2,%edx
  8010e5:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  8010ea:	eb 15                	jmp    801101 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  8010ec:	84 c0                	test   %al,%al
  8010ee:	66 90                	xchg   %ax,%ax
  8010f0:	74 0f                	je     801101 <strtol+0x86>
  8010f2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  8010f7:	80 3a 30             	cmpb   $0x30,(%edx)
  8010fa:	75 05                	jne    801101 <strtol+0x86>
		s++, base = 8;
  8010fc:	83 c2 01             	add    $0x1,%edx
  8010ff:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  801101:	b8 00 00 00 00       	mov    $0x0,%eax
  801106:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  801108:	0f b6 0a             	movzbl (%edx),%ecx
  80110b:	89 cf                	mov    %ecx,%edi
  80110d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  801110:	80 fb 09             	cmp    $0x9,%bl
  801113:	77 08                	ja     80111d <strtol+0xa2>
			dig = *s - '0';
  801115:	0f be c9             	movsbl %cl,%ecx
  801118:	83 e9 30             	sub    $0x30,%ecx
  80111b:	eb 1e                	jmp    80113b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  80111d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  801120:	80 fb 19             	cmp    $0x19,%bl
  801123:	77 08                	ja     80112d <strtol+0xb2>
			dig = *s - 'a' + 10;
  801125:	0f be c9             	movsbl %cl,%ecx
  801128:	83 e9 57             	sub    $0x57,%ecx
  80112b:	eb 0e                	jmp    80113b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  80112d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  801130:	80 fb 19             	cmp    $0x19,%bl
  801133:	77 15                	ja     80114a <strtol+0xcf>
			dig = *s - 'A' + 10;
  801135:	0f be c9             	movsbl %cl,%ecx
  801138:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  80113b:	39 f1                	cmp    %esi,%ecx
  80113d:	7d 0b                	jge    80114a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  80113f:	83 c2 01             	add    $0x1,%edx
  801142:	0f af c6             	imul   %esi,%eax
  801145:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  801148:	eb be                	jmp    801108 <strtol+0x8d>
  80114a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  80114c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801150:	74 05                	je     801157 <strtol+0xdc>
		*endptr = (char *) s;
  801152:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  801155:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  801157:	89 ca                	mov    %ecx,%edx
  801159:	f7 da                	neg    %edx
  80115b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  80115f:	0f 45 c2             	cmovne %edx,%eax
}
  801162:	83 c4 04             	add    $0x4,%esp
  801165:	5b                   	pop    %ebx
  801166:	5e                   	pop    %esi
  801167:	5f                   	pop    %edi
  801168:	5d                   	pop    %ebp
  801169:	c3                   	ret    
	...

0080116c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  80116c:	55                   	push   %ebp
  80116d:	89 e5                	mov    %esp,%ebp
  80116f:	83 ec 0c             	sub    $0xc,%esp
  801172:	89 1c 24             	mov    %ebx,(%esp)
  801175:	89 74 24 04          	mov    %esi,0x4(%esp)
  801179:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80117d:	ba 00 00 00 00       	mov    $0x0,%edx
  801182:	b8 01 00 00 00       	mov    $0x1,%eax
  801187:	89 d1                	mov    %edx,%ecx
  801189:	89 d3                	mov    %edx,%ebx
  80118b:	89 d7                	mov    %edx,%edi
  80118d:	89 d6                	mov    %edx,%esi
  80118f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  801191:	8b 1c 24             	mov    (%esp),%ebx
  801194:	8b 74 24 04          	mov    0x4(%esp),%esi
  801198:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80119c:	89 ec                	mov    %ebp,%esp
  80119e:	5d                   	pop    %ebp
  80119f:	c3                   	ret    

008011a0 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  8011a0:	55                   	push   %ebp
  8011a1:	89 e5                	mov    %esp,%ebp
  8011a3:	83 ec 0c             	sub    $0xc,%esp
  8011a6:	89 1c 24             	mov    %ebx,(%esp)
  8011a9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8011ad:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011b1:	b8 00 00 00 00       	mov    $0x0,%eax
  8011b6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011b9:	8b 55 08             	mov    0x8(%ebp),%edx
  8011bc:	89 c3                	mov    %eax,%ebx
  8011be:	89 c7                	mov    %eax,%edi
  8011c0:	89 c6                	mov    %eax,%esi
  8011c2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  8011c4:	8b 1c 24             	mov    (%esp),%ebx
  8011c7:	8b 74 24 04          	mov    0x4(%esp),%esi
  8011cb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8011cf:	89 ec                	mov    %ebp,%esp
  8011d1:	5d                   	pop    %ebp
  8011d2:	c3                   	ret    

008011d3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  8011d3:	55                   	push   %ebp
  8011d4:	89 e5                	mov    %esp,%ebp
  8011d6:	83 ec 0c             	sub    $0xc,%esp
  8011d9:	89 1c 24             	mov    %ebx,(%esp)
  8011dc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8011e0:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011e4:	bb 00 00 00 00       	mov    $0x0,%ebx
  8011e9:	b8 10 00 00 00       	mov    $0x10,%eax
  8011ee:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011f1:	8b 55 08             	mov    0x8(%ebp),%edx
  8011f4:	89 df                	mov    %ebx,%edi
  8011f6:	89 de                	mov    %ebx,%esi
  8011f8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  8011fa:	8b 1c 24             	mov    (%esp),%ebx
  8011fd:	8b 74 24 04          	mov    0x4(%esp),%esi
  801201:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801205:	89 ec                	mov    %ebp,%esp
  801207:	5d                   	pop    %ebp
  801208:	c3                   	ret    

00801209 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  801209:	55                   	push   %ebp
  80120a:	89 e5                	mov    %esp,%ebp
  80120c:	83 ec 0c             	sub    $0xc,%esp
  80120f:	89 1c 24             	mov    %ebx,(%esp)
  801212:	89 74 24 04          	mov    %esi,0x4(%esp)
  801216:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80121a:	bb 00 00 00 00       	mov    $0x0,%ebx
  80121f:	b8 0f 00 00 00       	mov    $0xf,%eax
  801224:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801227:	8b 55 08             	mov    0x8(%ebp),%edx
  80122a:	89 df                	mov    %ebx,%edi
  80122c:	89 de                	mov    %ebx,%esi
  80122e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  801230:	8b 1c 24             	mov    (%esp),%ebx
  801233:	8b 74 24 04          	mov    0x4(%esp),%esi
  801237:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80123b:	89 ec                	mov    %ebp,%esp
  80123d:	5d                   	pop    %ebp
  80123e:	c3                   	ret    

0080123f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  80123f:	55                   	push   %ebp
  801240:	89 e5                	mov    %esp,%ebp
  801242:	83 ec 0c             	sub    $0xc,%esp
  801245:	89 1c 24             	mov    %ebx,(%esp)
  801248:	89 74 24 04          	mov    %esi,0x4(%esp)
  80124c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801250:	ba 00 00 00 00       	mov    $0x0,%edx
  801255:	b8 0e 00 00 00       	mov    $0xe,%eax
  80125a:	89 d1                	mov    %edx,%ecx
  80125c:	89 d3                	mov    %edx,%ebx
  80125e:	89 d7                	mov    %edx,%edi
  801260:	89 d6                	mov    %edx,%esi
  801262:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  801264:	8b 1c 24             	mov    (%esp),%ebx
  801267:	8b 74 24 04          	mov    0x4(%esp),%esi
  80126b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80126f:	89 ec                	mov    %ebp,%esp
  801271:	5d                   	pop    %ebp
  801272:	c3                   	ret    

00801273 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  801273:	55                   	push   %ebp
  801274:	89 e5                	mov    %esp,%ebp
  801276:	83 ec 38             	sub    $0x38,%esp
  801279:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80127c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80127f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801282:	b9 00 00 00 00       	mov    $0x0,%ecx
  801287:	b8 0d 00 00 00       	mov    $0xd,%eax
  80128c:	8b 55 08             	mov    0x8(%ebp),%edx
  80128f:	89 cb                	mov    %ecx,%ebx
  801291:	89 cf                	mov    %ecx,%edi
  801293:	89 ce                	mov    %ecx,%esi
  801295:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801297:	85 c0                	test   %eax,%eax
  801299:	7e 28                	jle    8012c3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  80129b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80129f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  8012a6:	00 
  8012a7:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  8012ae:	00 
  8012af:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8012b6:	00 
  8012b7:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  8012be:	e8 4d f3 ff ff       	call   800610 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  8012c3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8012c6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8012c9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8012cc:	89 ec                	mov    %ebp,%esp
  8012ce:	5d                   	pop    %ebp
  8012cf:	c3                   	ret    

008012d0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  8012d0:	55                   	push   %ebp
  8012d1:	89 e5                	mov    %esp,%ebp
  8012d3:	83 ec 38             	sub    $0x38,%esp
  8012d6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8012d9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8012dc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012df:	be 00 00 00 00       	mov    $0x0,%esi
  8012e4:	b8 0c 00 00 00       	mov    $0xc,%eax
  8012e9:	8b 7d 14             	mov    0x14(%ebp),%edi
  8012ec:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8012ef:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8012f2:	8b 55 08             	mov    0x8(%ebp),%edx
  8012f5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8012f7:	85 c0                	test   %eax,%eax
  8012f9:	7e 28                	jle    801323 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  8012fb:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012ff:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  801306:	00 
  801307:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  80130e:	00 
  80130f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801316:	00 
  801317:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  80131e:	e8 ed f2 ff ff       	call   800610 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801323:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801326:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801329:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80132c:	89 ec                	mov    %ebp,%esp
  80132e:	5d                   	pop    %ebp
  80132f:	c3                   	ret    

00801330 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801330:	55                   	push   %ebp
  801331:	89 e5                	mov    %esp,%ebp
  801333:	83 ec 38             	sub    $0x38,%esp
  801336:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801339:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80133c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80133f:	bb 00 00 00 00       	mov    $0x0,%ebx
  801344:	b8 0a 00 00 00       	mov    $0xa,%eax
  801349:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80134c:	8b 55 08             	mov    0x8(%ebp),%edx
  80134f:	89 df                	mov    %ebx,%edi
  801351:	89 de                	mov    %ebx,%esi
  801353:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801355:	85 c0                	test   %eax,%eax
  801357:	7e 28                	jle    801381 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801359:	89 44 24 10          	mov    %eax,0x10(%esp)
  80135d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  801364:	00 
  801365:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  80136c:	00 
  80136d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801374:	00 
  801375:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  80137c:	e8 8f f2 ff ff       	call   800610 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  801381:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801384:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801387:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80138a:	89 ec                	mov    %ebp,%esp
  80138c:	5d                   	pop    %ebp
  80138d:	c3                   	ret    

0080138e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  80138e:	55                   	push   %ebp
  80138f:	89 e5                	mov    %esp,%ebp
  801391:	83 ec 38             	sub    $0x38,%esp
  801394:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801397:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80139a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80139d:	bb 00 00 00 00       	mov    $0x0,%ebx
  8013a2:	b8 09 00 00 00       	mov    $0x9,%eax
  8013a7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8013aa:	8b 55 08             	mov    0x8(%ebp),%edx
  8013ad:	89 df                	mov    %ebx,%edi
  8013af:	89 de                	mov    %ebx,%esi
  8013b1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8013b3:	85 c0                	test   %eax,%eax
  8013b5:	7e 28                	jle    8013df <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8013b7:	89 44 24 10          	mov    %eax,0x10(%esp)
  8013bb:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  8013c2:	00 
  8013c3:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  8013ca:	00 
  8013cb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8013d2:	00 
  8013d3:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  8013da:	e8 31 f2 ff ff       	call   800610 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  8013df:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8013e2:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8013e5:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8013e8:	89 ec                	mov    %ebp,%esp
  8013ea:	5d                   	pop    %ebp
  8013eb:	c3                   	ret    

008013ec <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  8013ec:	55                   	push   %ebp
  8013ed:	89 e5                	mov    %esp,%ebp
  8013ef:	83 ec 38             	sub    $0x38,%esp
  8013f2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8013f5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8013f8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8013fb:	bb 00 00 00 00       	mov    $0x0,%ebx
  801400:	b8 08 00 00 00       	mov    $0x8,%eax
  801405:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801408:	8b 55 08             	mov    0x8(%ebp),%edx
  80140b:	89 df                	mov    %ebx,%edi
  80140d:	89 de                	mov    %ebx,%esi
  80140f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801411:	85 c0                	test   %eax,%eax
  801413:	7e 28                	jle    80143d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801415:	89 44 24 10          	mov    %eax,0x10(%esp)
  801419:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801420:	00 
  801421:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  801428:	00 
  801429:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801430:	00 
  801431:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  801438:	e8 d3 f1 ff ff       	call   800610 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80143d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801440:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801443:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801446:	89 ec                	mov    %ebp,%esp
  801448:	5d                   	pop    %ebp
  801449:	c3                   	ret    

0080144a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80144a:	55                   	push   %ebp
  80144b:	89 e5                	mov    %esp,%ebp
  80144d:	83 ec 38             	sub    $0x38,%esp
  801450:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801453:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801456:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801459:	bb 00 00 00 00       	mov    $0x0,%ebx
  80145e:	b8 06 00 00 00       	mov    $0x6,%eax
  801463:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801466:	8b 55 08             	mov    0x8(%ebp),%edx
  801469:	89 df                	mov    %ebx,%edi
  80146b:	89 de                	mov    %ebx,%esi
  80146d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80146f:	85 c0                	test   %eax,%eax
  801471:	7e 28                	jle    80149b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801473:	89 44 24 10          	mov    %eax,0x10(%esp)
  801477:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80147e:	00 
  80147f:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  801486:	00 
  801487:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80148e:	00 
  80148f:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  801496:	e8 75 f1 ff ff       	call   800610 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80149b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80149e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8014a1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8014a4:	89 ec                	mov    %ebp,%esp
  8014a6:	5d                   	pop    %ebp
  8014a7:	c3                   	ret    

008014a8 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8014a8:	55                   	push   %ebp
  8014a9:	89 e5                	mov    %esp,%ebp
  8014ab:	83 ec 38             	sub    $0x38,%esp
  8014ae:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8014b1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8014b4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8014b7:	b8 05 00 00 00       	mov    $0x5,%eax
  8014bc:	8b 75 18             	mov    0x18(%ebp),%esi
  8014bf:	8b 7d 14             	mov    0x14(%ebp),%edi
  8014c2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8014c5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8014c8:	8b 55 08             	mov    0x8(%ebp),%edx
  8014cb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8014cd:	85 c0                	test   %eax,%eax
  8014cf:	7e 28                	jle    8014f9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8014d1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8014d5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8014dc:	00 
  8014dd:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  8014e4:	00 
  8014e5:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8014ec:	00 
  8014ed:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  8014f4:	e8 17 f1 ff ff       	call   800610 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  8014f9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8014fc:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8014ff:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801502:	89 ec                	mov    %ebp,%esp
  801504:	5d                   	pop    %ebp
  801505:	c3                   	ret    

00801506 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801506:	55                   	push   %ebp
  801507:	89 e5                	mov    %esp,%ebp
  801509:	83 ec 38             	sub    $0x38,%esp
  80150c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80150f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801512:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801515:	be 00 00 00 00       	mov    $0x0,%esi
  80151a:	b8 04 00 00 00       	mov    $0x4,%eax
  80151f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801522:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801525:	8b 55 08             	mov    0x8(%ebp),%edx
  801528:	89 f7                	mov    %esi,%edi
  80152a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80152c:	85 c0                	test   %eax,%eax
  80152e:	7e 28                	jle    801558 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801530:	89 44 24 10          	mov    %eax,0x10(%esp)
  801534:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80153b:	00 
  80153c:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  801543:	00 
  801544:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80154b:	00 
  80154c:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  801553:	e8 b8 f0 ff ff       	call   800610 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801558:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80155b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80155e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801561:	89 ec                	mov    %ebp,%esp
  801563:	5d                   	pop    %ebp
  801564:	c3                   	ret    

00801565 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801565:	55                   	push   %ebp
  801566:	89 e5                	mov    %esp,%ebp
  801568:	83 ec 0c             	sub    $0xc,%esp
  80156b:	89 1c 24             	mov    %ebx,(%esp)
  80156e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801572:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801576:	ba 00 00 00 00       	mov    $0x0,%edx
  80157b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801580:	89 d1                	mov    %edx,%ecx
  801582:	89 d3                	mov    %edx,%ebx
  801584:	89 d7                	mov    %edx,%edi
  801586:	89 d6                	mov    %edx,%esi
  801588:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80158a:	8b 1c 24             	mov    (%esp),%ebx
  80158d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801591:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801595:	89 ec                	mov    %ebp,%esp
  801597:	5d                   	pop    %ebp
  801598:	c3                   	ret    

00801599 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801599:	55                   	push   %ebp
  80159a:	89 e5                	mov    %esp,%ebp
  80159c:	83 ec 0c             	sub    $0xc,%esp
  80159f:	89 1c 24             	mov    %ebx,(%esp)
  8015a2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8015a6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8015aa:	ba 00 00 00 00       	mov    $0x0,%edx
  8015af:	b8 02 00 00 00       	mov    $0x2,%eax
  8015b4:	89 d1                	mov    %edx,%ecx
  8015b6:	89 d3                	mov    %edx,%ebx
  8015b8:	89 d7                	mov    %edx,%edi
  8015ba:	89 d6                	mov    %edx,%esi
  8015bc:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8015be:	8b 1c 24             	mov    (%esp),%ebx
  8015c1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8015c5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8015c9:	89 ec                	mov    %ebp,%esp
  8015cb:	5d                   	pop    %ebp
  8015cc:	c3                   	ret    

008015cd <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8015cd:	55                   	push   %ebp
  8015ce:	89 e5                	mov    %esp,%ebp
  8015d0:	83 ec 38             	sub    $0x38,%esp
  8015d3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8015d6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8015d9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8015dc:	b9 00 00 00 00       	mov    $0x0,%ecx
  8015e1:	b8 03 00 00 00       	mov    $0x3,%eax
  8015e6:	8b 55 08             	mov    0x8(%ebp),%edx
  8015e9:	89 cb                	mov    %ecx,%ebx
  8015eb:	89 cf                	mov    %ecx,%edi
  8015ed:	89 ce                	mov    %ecx,%esi
  8015ef:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8015f1:	85 c0                	test   %eax,%eax
  8015f3:	7e 28                	jle    80161d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8015f5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8015f9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801600:	00 
  801601:	c7 44 24 08 8b 3b 80 	movl   $0x803b8b,0x8(%esp)
  801608:	00 
  801609:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801610:	00 
  801611:	c7 04 24 a8 3b 80 00 	movl   $0x803ba8,(%esp)
  801618:	e8 f3 ef ff ff       	call   800610 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80161d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801620:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801623:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801626:	89 ec                	mov    %ebp,%esp
  801628:	5d                   	pop    %ebp
  801629:	c3                   	ret    
  80162a:	00 00                	add    %al,(%eax)
  80162c:	00 00                	add    %al,(%eax)
	...

00801630 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801630:	55                   	push   %ebp
  801631:	89 e5                	mov    %esp,%ebp
  801633:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801636:	c7 44 24 08 b6 3b 80 	movl   $0x803bb6,0x8(%esp)
  80163d:	00 
  80163e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  801645:	00 
  801646:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  80164d:	e8 be ef ff ff       	call   800610 <_panic>

00801652 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801652:	55                   	push   %ebp
  801653:	89 e5                	mov    %esp,%ebp
  801655:	57                   	push   %edi
  801656:	56                   	push   %esi
  801657:	53                   	push   %ebx
  801658:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  80165b:	c7 04 24 bc 18 80 00 	movl   $0x8018bc,(%esp)
  801662:	e8 39 1c 00 00       	call   8032a0 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801667:	ba 07 00 00 00       	mov    $0x7,%edx
  80166c:	89 d0                	mov    %edx,%eax
  80166e:	cd 30                	int    $0x30
  801670:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  801673:	85 c0                	test   %eax,%eax
  801675:	79 20                	jns    801697 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  801677:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80167b:	c7 44 24 08 3c 3c 80 	movl   $0x803c3c,0x8(%esp)
  801682:	00 
  801683:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  80168a:	00 
  80168b:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  801692:	e8 79 ef ff ff       	call   800610 <_panic>
    } else if (childId>0) {
  801697:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80169b:	0f 8e f3 01 00 00    	jle    801894 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  8016a1:	c7 44 24 04 10 33 80 	movl   $0x803310,0x4(%esp)
  8016a8:	00 
  8016a9:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8016ac:	89 04 24             	mov    %eax,(%esp)
  8016af:	e8 7c fc ff ff       	call   801330 <sys_env_set_pgfault_upcall>
  8016b4:	85 c0                	test   %eax,%eax
  8016b6:	74 20                	je     8016d8 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  8016b8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8016bc:	c7 44 24 08 60 3c 80 	movl   $0x803c60,0x8(%esp)
  8016c3:	00 
  8016c4:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  8016cb:	00 
  8016cc:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  8016d3:	e8 38 ef ff ff       	call   800610 <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  8016d8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8016df:	00 
  8016e0:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  8016e7:	ee 
  8016e8:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8016eb:	89 04 24             	mov    %eax,(%esp)
  8016ee:	e8 13 fe ff ff       	call   801506 <sys_page_alloc>
  8016f3:	85 c0                	test   %eax,%eax
  8016f5:	79 20                	jns    801717 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  8016f7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8016fb:	c7 44 24 08 90 3c 80 	movl   $0x803c90,0x8(%esp)
  801702:	00 
  801703:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80170a:	00 
  80170b:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  801712:	e8 f9 ee ff ff       	call   800610 <_panic>
  801717:	be 00 00 80 00       	mov    $0x800000,%esi
  80171c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801721:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801726:	89 f0                	mov    %esi,%eax
  801728:	c1 e8 16             	shr    $0x16,%eax
  80172b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80172e:	a8 01                	test   $0x1,%al
  801730:	0f 84 13 01 00 00    	je     801849 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801736:	89 f0                	mov    %esi,%eax
  801738:	c1 e8 0c             	shr    $0xc,%eax
  80173b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801742:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801745:	25 07 0e 00 00       	and    $0xe07,%eax
  80174a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  80174d:	e8 47 fe ff ff       	call   801599 <sys_getenvid>
  801752:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  801755:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  801759:	0f 84 ea 00 00 00    	je     801849 <fork+0x1f7>
  80175f:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  801766:	0f 84 9d 00 00 00    	je     801809 <fork+0x1b7>
  80176c:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  801773:	0f 85 90 00 00 00    	jne    801809 <fork+0x1b7>
    perm    &= (~PTE_W);
  801779:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80177c:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  80177f:	80 cc 08             	or     $0x8,%ah
  801782:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801785:	89 75 e0             	mov    %esi,-0x20(%ebp)
  801788:	89 44 24 10          	mov    %eax,0x10(%esp)
  80178c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801790:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801793:	89 44 24 08          	mov    %eax,0x8(%esp)
  801797:	89 74 24 04          	mov    %esi,0x4(%esp)
  80179b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80179e:	89 04 24             	mov    %eax,(%esp)
  8017a1:	e8 02 fd ff ff       	call   8014a8 <sys_page_map>
  8017a6:	85 c0                	test   %eax,%eax
  8017a8:	79 1b                	jns    8017c5 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  8017aa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8017ae:	89 74 24 08          	mov    %esi,0x8(%esp)
  8017b2:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8017b5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017b9:	c7 04 24 b8 3c 80 00 	movl   $0x803cb8,(%esp)
  8017c0:	e8 10 ef ff ff       	call   8006d5 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  8017c5:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8017c8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8017cc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8017cf:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8017d3:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8017d6:	89 44 24 08          	mov    %eax,0x8(%esp)
  8017da:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8017dd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017e1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8017e4:	89 04 24             	mov    %eax,(%esp)
  8017e7:	e8 bc fc ff ff       	call   8014a8 <sys_page_map>
  8017ec:	85 c0                	test   %eax,%eax
  8017ee:	79 59                	jns    801849 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  8017f0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8017f4:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8017f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017fb:	c7 04 24 f8 3c 80 00 	movl   $0x803cf8,(%esp)
  801802:	e8 ce ee ff ff       	call   8006d5 <cprintf>
  801807:	eb 40                	jmp    801849 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801809:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80180c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801810:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801814:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801817:	89 44 24 08          	mov    %eax,0x8(%esp)
  80181b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80181f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801822:	89 04 24             	mov    %eax,(%esp)
  801825:	e8 7e fc ff ff       	call   8014a8 <sys_page_map>
  80182a:	85 c0                	test   %eax,%eax
  80182c:	79 1b                	jns    801849 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80182e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801832:	89 74 24 08          	mov    %esi,0x8(%esp)
  801836:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801839:	89 44 24 04          	mov    %eax,0x4(%esp)
  80183d:	c7 04 24 b8 3c 80 00 	movl   $0x803cb8,(%esp)
  801844:	e8 8c ee ff ff       	call   8006d5 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  801849:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  80184f:	89 de                	mov    %ebx,%esi
  801851:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  801857:	0f 85 c9 fe ff ff    	jne    801726 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  80185d:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801864:	00 
  801865:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801868:	89 04 24             	mov    %eax,(%esp)
  80186b:	e8 7c fb ff ff       	call   8013ec <sys_env_set_status>
  801870:	85 c0                	test   %eax,%eax
  801872:	79 3d                	jns    8018b1 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  801874:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801878:	c7 44 24 08 2c 3d 80 	movl   $0x803d2c,0x8(%esp)
  80187f:	00 
  801880:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  801887:	00 
  801888:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  80188f:	e8 7c ed ff ff       	call   800610 <_panic>
    } else if (childId==0) {
  801894:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801898:	75 17                	jne    8018b1 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  80189a:	e8 fa fc ff ff       	call   801599 <sys_getenvid>
  80189f:	25 ff 03 00 00       	and    $0x3ff,%eax
  8018a4:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8018a7:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8018ac:	a3 74 70 80 00       	mov    %eax,0x807074
    }
    return childId;
}
  8018b1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8018b4:	83 c4 3c             	add    $0x3c,%esp
  8018b7:	5b                   	pop    %ebx
  8018b8:	5e                   	pop    %esi
  8018b9:	5f                   	pop    %edi
  8018ba:	5d                   	pop    %ebp
  8018bb:	c3                   	ret    

008018bc <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  8018bc:	55                   	push   %ebp
  8018bd:	89 e5                	mov    %esp,%ebp
  8018bf:	57                   	push   %edi
  8018c0:	56                   	push   %esi
  8018c1:	53                   	push   %ebx
  8018c2:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  8018c5:	8b 45 08             	mov    0x8(%ebp),%eax
  8018c8:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  8018ca:	8b 50 04             	mov    0x4(%eax),%edx
  8018cd:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  8018d0:	89 fe                	mov    %edi,%esi
  8018d2:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  8018d8:	e8 bc fc ff ff       	call   801599 <sys_getenvid>
  8018dd:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  8018df:	89 f2                	mov    %esi,%edx
  8018e1:	89 f0                	mov    %esi,%eax
  8018e3:	c1 e8 16             	shr    $0x16,%eax
  8018e6:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8018ed:	a8 01                	test   $0x1,%al
  8018ef:	74 3e                	je     80192f <pgfault+0x73>
  8018f1:	c1 ea 0c             	shr    $0xc,%edx
  8018f4:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8018fb:	a8 01                	test   $0x1,%al
  8018fd:	74 30                	je     80192f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  8018ff:	c1 ef 0c             	shr    $0xc,%edi
  801902:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801909:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80190f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801912:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801916:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80191d:	00 
  80191e:	89 1c 24             	mov    %ebx,(%esp)
  801921:	e8 e0 fb ff ff       	call   801506 <sys_page_alloc>
  801926:	85 c0                	test   %eax,%eax
  801928:	74 46                	je     801970 <pgfault+0xb4>
  80192a:	e9 cd 00 00 00       	jmp    8019fc <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80192f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801932:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801936:	8b 55 08             	mov    0x8(%ebp),%edx
  801939:	8b 42 28             	mov    0x28(%edx),%eax
  80193c:	89 44 24 08          	mov    %eax,0x8(%esp)
  801940:	89 74 24 04          	mov    %esi,0x4(%esp)
  801944:	c7 04 24 4c 3d 80 00 	movl   $0x803d4c,(%esp)
  80194b:	e8 85 ed ff ff       	call   8006d5 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  801950:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801954:	c7 44 24 08 d7 3b 80 	movl   $0x803bd7,0x8(%esp)
  80195b:	00 
  80195c:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  801963:	00 
  801964:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  80196b:	e8 a0 ec ff ff       	call   800610 <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  801970:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  801977:	00 
  801978:	89 74 24 04          	mov    %esi,0x4(%esp)
  80197c:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  801983:	e8 dd f5 ff ff       	call   800f65 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  801988:	89 7c 24 10          	mov    %edi,0x10(%esp)
  80198c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801990:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801994:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80199b:	00 
  80199c:	89 1c 24             	mov    %ebx,(%esp)
  80199f:	e8 04 fb ff ff       	call   8014a8 <sys_page_map>
  8019a4:	85 c0                	test   %eax,%eax
  8019a6:	74 20                	je     8019c8 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  8019a8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8019ac:	c7 44 24 08 e9 3b 80 	movl   $0x803be9,0x8(%esp)
  8019b3:	00 
  8019b4:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  8019bb:	00 
  8019bc:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  8019c3:	e8 48 ec ff ff       	call   800610 <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  8019c8:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8019cf:	00 
  8019d0:	89 1c 24             	mov    %ebx,(%esp)
  8019d3:	e8 72 fa ff ff       	call   80144a <sys_page_unmap>
  8019d8:	85 c0                	test   %eax,%eax
  8019da:	74 40                	je     801a1c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  8019dc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8019e0:	c7 44 24 08 04 3c 80 	movl   $0x803c04,0x8(%esp)
  8019e7:	00 
  8019e8:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  8019ef:	00 
  8019f0:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  8019f7:	e8 14 ec ff ff       	call   800610 <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  8019fc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801a00:	c7 44 24 08 21 3c 80 	movl   $0x803c21,0x8(%esp)
  801a07:	00 
  801a08:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  801a0f:	00 
  801a10:	c7 04 24 cc 3b 80 00 	movl   $0x803bcc,(%esp)
  801a17:	e8 f4 eb ff ff       	call   800610 <_panic>
}
  801a1c:	83 c4 3c             	add    $0x3c,%esp
  801a1f:	5b                   	pop    %ebx
  801a20:	5e                   	pop    %esi
  801a21:	5f                   	pop    %edi
  801a22:	5d                   	pop    %ebp
  801a23:	c3                   	ret    
	...

00801a30 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801a30:	55                   	push   %ebp
  801a31:	89 e5                	mov    %esp,%ebp
  801a33:	8b 45 08             	mov    0x8(%ebp),%eax
  801a36:	05 00 00 00 30       	add    $0x30000000,%eax
  801a3b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  801a3e:	5d                   	pop    %ebp
  801a3f:	c3                   	ret    

00801a40 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801a40:	55                   	push   %ebp
  801a41:	89 e5                	mov    %esp,%ebp
  801a43:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801a46:	8b 45 08             	mov    0x8(%ebp),%eax
  801a49:	89 04 24             	mov    %eax,(%esp)
  801a4c:	e8 df ff ff ff       	call   801a30 <fd2num>
  801a51:	05 20 00 0d 00       	add    $0xd0020,%eax
  801a56:	c1 e0 0c             	shl    $0xc,%eax
}
  801a59:	c9                   	leave  
  801a5a:	c3                   	ret    

00801a5b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  801a5b:	55                   	push   %ebp
  801a5c:	89 e5                	mov    %esp,%ebp
  801a5e:	57                   	push   %edi
  801a5f:	56                   	push   %esi
  801a60:	53                   	push   %ebx
  801a61:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801a64:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801a69:	a8 01                	test   $0x1,%al
  801a6b:	74 36                	je     801aa3 <fd_alloc+0x48>
  801a6d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801a72:	a8 01                	test   $0x1,%al
  801a74:	74 2d                	je     801aa3 <fd_alloc+0x48>
  801a76:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  801a7b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801a80:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801a85:	89 c3                	mov    %eax,%ebx
  801a87:	89 c2                	mov    %eax,%edx
  801a89:	c1 ea 16             	shr    $0x16,%edx
  801a8c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  801a8f:	f6 c2 01             	test   $0x1,%dl
  801a92:	74 14                	je     801aa8 <fd_alloc+0x4d>
  801a94:	89 c2                	mov    %eax,%edx
  801a96:	c1 ea 0c             	shr    $0xc,%edx
  801a99:	8b 14 96             	mov    (%esi,%edx,4),%edx
  801a9c:	f6 c2 01             	test   $0x1,%dl
  801a9f:	75 10                	jne    801ab1 <fd_alloc+0x56>
  801aa1:	eb 05                	jmp    801aa8 <fd_alloc+0x4d>
  801aa3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801aa8:	89 1f                	mov    %ebx,(%edi)
  801aaa:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  801aaf:	eb 17                	jmp    801ac8 <fd_alloc+0x6d>
  801ab1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801ab6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  801abb:	75 c8                	jne    801a85 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  801abd:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801ac3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801ac8:	5b                   	pop    %ebx
  801ac9:	5e                   	pop    %esi
  801aca:	5f                   	pop    %edi
  801acb:	5d                   	pop    %ebp
  801acc:	c3                   	ret    

00801acd <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  801acd:	55                   	push   %ebp
  801ace:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801ad0:	8b 45 08             	mov    0x8(%ebp),%eax
  801ad3:	83 f8 1f             	cmp    $0x1f,%eax
  801ad6:	77 36                	ja     801b0e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801ad8:	05 00 00 0d 00       	add    $0xd0000,%eax
  801add:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801ae0:	89 c2                	mov    %eax,%edx
  801ae2:	c1 ea 16             	shr    $0x16,%edx
  801ae5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  801aec:	f6 c2 01             	test   $0x1,%dl
  801aef:	74 1d                	je     801b0e <fd_lookup+0x41>
  801af1:	89 c2                	mov    %eax,%edx
  801af3:	c1 ea 0c             	shr    $0xc,%edx
  801af6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801afd:	f6 c2 01             	test   $0x1,%dl
  801b00:	74 0c                	je     801b0e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801b02:	8b 55 0c             	mov    0xc(%ebp),%edx
  801b05:	89 02                	mov    %eax,(%edx)
  801b07:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  801b0c:	eb 05                	jmp    801b13 <fd_lookup+0x46>
  801b0e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801b13:	5d                   	pop    %ebp
  801b14:	c3                   	ret    

00801b15 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801b15:	55                   	push   %ebp
  801b16:	89 e5                	mov    %esp,%ebp
  801b18:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801b1b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  801b1e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b22:	8b 45 08             	mov    0x8(%ebp),%eax
  801b25:	89 04 24             	mov    %eax,(%esp)
  801b28:	e8 a0 ff ff ff       	call   801acd <fd_lookup>
  801b2d:	85 c0                	test   %eax,%eax
  801b2f:	78 0e                	js     801b3f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801b31:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801b34:	8b 55 0c             	mov    0xc(%ebp),%edx
  801b37:	89 50 04             	mov    %edx,0x4(%eax)
  801b3a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801b3f:	c9                   	leave  
  801b40:	c3                   	ret    

00801b41 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801b41:	55                   	push   %ebp
  801b42:	89 e5                	mov    %esp,%ebp
  801b44:	56                   	push   %esi
  801b45:	53                   	push   %ebx
  801b46:	83 ec 10             	sub    $0x10,%esp
  801b49:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801b4c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  801b4f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801b54:	b8 20 70 80 00       	mov    $0x807020,%eax
  801b59:	39 0d 20 70 80 00    	cmp    %ecx,0x807020
  801b5f:	75 11                	jne    801b72 <dev_lookup+0x31>
  801b61:	eb 04                	jmp    801b67 <dev_lookup+0x26>
  801b63:	39 08                	cmp    %ecx,(%eax)
  801b65:	75 10                	jne    801b77 <dev_lookup+0x36>
			*dev = devtab[i];
  801b67:	89 03                	mov    %eax,(%ebx)
  801b69:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  801b6e:	66 90                	xchg   %ax,%ax
  801b70:	eb 36                	jmp    801ba8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801b72:	be f4 3d 80 00       	mov    $0x803df4,%esi
  801b77:	83 c2 01             	add    $0x1,%edx
  801b7a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  801b7d:	85 c0                	test   %eax,%eax
  801b7f:	75 e2                	jne    801b63 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801b81:	a1 74 70 80 00       	mov    0x807074,%eax
  801b86:	8b 40 4c             	mov    0x4c(%eax),%eax
  801b89:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801b8d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b91:	c7 04 24 78 3d 80 00 	movl   $0x803d78,(%esp)
  801b98:	e8 38 eb ff ff       	call   8006d5 <cprintf>
	*dev = 0;
  801b9d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801ba3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801ba8:	83 c4 10             	add    $0x10,%esp
  801bab:	5b                   	pop    %ebx
  801bac:	5e                   	pop    %esi
  801bad:	5d                   	pop    %ebp
  801bae:	c3                   	ret    

00801baf <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  801baf:	55                   	push   %ebp
  801bb0:	89 e5                	mov    %esp,%ebp
  801bb2:	53                   	push   %ebx
  801bb3:	83 ec 24             	sub    $0x24,%esp
  801bb6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801bb9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801bbc:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bc0:	8b 45 08             	mov    0x8(%ebp),%eax
  801bc3:	89 04 24             	mov    %eax,(%esp)
  801bc6:	e8 02 ff ff ff       	call   801acd <fd_lookup>
  801bcb:	85 c0                	test   %eax,%eax
  801bcd:	78 53                	js     801c22 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801bcf:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801bd2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bd6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801bd9:	8b 00                	mov    (%eax),%eax
  801bdb:	89 04 24             	mov    %eax,(%esp)
  801bde:	e8 5e ff ff ff       	call   801b41 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801be3:	85 c0                	test   %eax,%eax
  801be5:	78 3b                	js     801c22 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801be7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801bec:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801bef:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801bf3:	74 2d                	je     801c22 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801bf5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801bf8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  801bff:	00 00 00 
	stat->st_isdir = 0;
  801c02:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801c09:	00 00 00 
	stat->st_dev = dev;
  801c0c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801c0f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801c15:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801c19:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801c1c:	89 14 24             	mov    %edx,(%esp)
  801c1f:	ff 50 14             	call   *0x14(%eax)
}
  801c22:	83 c4 24             	add    $0x24,%esp
  801c25:	5b                   	pop    %ebx
  801c26:	5d                   	pop    %ebp
  801c27:	c3                   	ret    

00801c28 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801c28:	55                   	push   %ebp
  801c29:	89 e5                	mov    %esp,%ebp
  801c2b:	53                   	push   %ebx
  801c2c:	83 ec 24             	sub    $0x24,%esp
  801c2f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801c32:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801c35:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c39:	89 1c 24             	mov    %ebx,(%esp)
  801c3c:	e8 8c fe ff ff       	call   801acd <fd_lookup>
  801c41:	85 c0                	test   %eax,%eax
  801c43:	78 5f                	js     801ca4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801c45:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801c48:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c4c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801c4f:	8b 00                	mov    (%eax),%eax
  801c51:	89 04 24             	mov    %eax,(%esp)
  801c54:	e8 e8 fe ff ff       	call   801b41 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801c59:	85 c0                	test   %eax,%eax
  801c5b:	78 47                	js     801ca4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801c5d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801c60:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801c64:	75 23                	jne    801c89 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801c66:	a1 74 70 80 00       	mov    0x807074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  801c6b:	8b 40 4c             	mov    0x4c(%eax),%eax
  801c6e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801c72:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c76:	c7 04 24 98 3d 80 00 	movl   $0x803d98,(%esp)
  801c7d:	e8 53 ea ff ff       	call   8006d5 <cprintf>
  801c82:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801c87:	eb 1b                	jmp    801ca4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801c89:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801c8c:	8b 48 18             	mov    0x18(%eax),%ecx
  801c8f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801c94:	85 c9                	test   %ecx,%ecx
  801c96:	74 0c                	je     801ca4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801c98:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c9b:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c9f:	89 14 24             	mov    %edx,(%esp)
  801ca2:	ff d1                	call   *%ecx
}
  801ca4:	83 c4 24             	add    $0x24,%esp
  801ca7:	5b                   	pop    %ebx
  801ca8:	5d                   	pop    %ebp
  801ca9:	c3                   	ret    

00801caa <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  801caa:	55                   	push   %ebp
  801cab:	89 e5                	mov    %esp,%ebp
  801cad:	53                   	push   %ebx
  801cae:	83 ec 24             	sub    $0x24,%esp
  801cb1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801cb4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801cb7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cbb:	89 1c 24             	mov    %ebx,(%esp)
  801cbe:	e8 0a fe ff ff       	call   801acd <fd_lookup>
  801cc3:	85 c0                	test   %eax,%eax
  801cc5:	78 66                	js     801d2d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801cc7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801cca:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cce:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801cd1:	8b 00                	mov    (%eax),%eax
  801cd3:	89 04 24             	mov    %eax,(%esp)
  801cd6:	e8 66 fe ff ff       	call   801b41 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801cdb:	85 c0                	test   %eax,%eax
  801cdd:	78 4e                	js     801d2d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801cdf:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801ce2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801ce6:	75 23                	jne    801d0b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801ce8:	a1 74 70 80 00       	mov    0x807074,%eax
  801ced:	8b 40 4c             	mov    0x4c(%eax),%eax
  801cf0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801cf4:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cf8:	c7 04 24 b9 3d 80 00 	movl   $0x803db9,(%esp)
  801cff:	e8 d1 e9 ff ff       	call   8006d5 <cprintf>
  801d04:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801d09:	eb 22                	jmp    801d2d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801d0b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d0e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801d11:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801d16:	85 c9                	test   %ecx,%ecx
  801d18:	74 13                	je     801d2d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801d1a:	8b 45 10             	mov    0x10(%ebp),%eax
  801d1d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d21:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d24:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d28:	89 14 24             	mov    %edx,(%esp)
  801d2b:	ff d1                	call   *%ecx
}
  801d2d:	83 c4 24             	add    $0x24,%esp
  801d30:	5b                   	pop    %ebx
  801d31:	5d                   	pop    %ebp
  801d32:	c3                   	ret    

00801d33 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801d33:	55                   	push   %ebp
  801d34:	89 e5                	mov    %esp,%ebp
  801d36:	57                   	push   %edi
  801d37:	56                   	push   %esi
  801d38:	53                   	push   %ebx
  801d39:	83 ec 2c             	sub    $0x2c,%esp
  801d3c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801d3f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801d42:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801d45:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d49:	89 1c 24             	mov    %ebx,(%esp)
  801d4c:	e8 7c fd ff ff       	call   801acd <fd_lookup>
  801d51:	85 c0                	test   %eax,%eax
  801d53:	0f 88 b0 00 00 00    	js     801e09 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801d59:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801d5c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d60:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801d63:	8b 00                	mov    (%eax),%eax
  801d65:	89 04 24             	mov    %eax,(%esp)
  801d68:	e8 d4 fd ff ff       	call   801b41 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801d6d:	85 c0                	test   %eax,%eax
  801d6f:	0f 88 94 00 00 00    	js     801e09 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801d75:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801d78:	8b 40 08             	mov    0x8(%eax),%eax
  801d7b:	83 e0 03             	and    $0x3,%eax
  801d7e:	83 f8 01             	cmp    $0x1,%eax
  801d81:	75 23                	jne    801da6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801d83:	a1 74 70 80 00       	mov    0x807074,%eax
  801d88:	8b 40 4c             	mov    0x4c(%eax),%eax
  801d8b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801d8f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d93:	c7 04 24 d6 3d 80 00 	movl   $0x803dd6,(%esp)
  801d9a:	e8 36 e9 ff ff       	call   8006d5 <cprintf>
  801d9f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801da4:	eb 63                	jmp    801e09 <read+0xd6>
	}
	if (!dev->dev_read)
  801da6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801dab:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801dae:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801db2:	74 55                	je     801e09 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801db4:	ba 00 00 00 00       	mov    $0x0,%edx
  801db9:	bb 00 00 00 00       	mov    $0x0,%ebx
  801dbe:	b8 00 00 00 00       	mov    $0x0,%eax
  801dc3:	85 f6                	test   %esi,%esi
  801dc5:	74 42                	je     801e09 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801dc7:	bf 00 10 00 00       	mov    $0x1000,%edi
  801dcc:	89 f0                	mov    %esi,%eax
  801dce:	29 d0                	sub    %edx,%eax
  801dd0:	89 c1                	mov    %eax,%ecx
  801dd2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801dd8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801ddd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801de0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801de4:	03 55 0c             	add    0xc(%ebp),%edx
  801de7:	89 54 24 04          	mov    %edx,0x4(%esp)
  801deb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801dee:	89 04 24             	mov    %eax,(%esp)
  801df1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801df4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801df7:	85 c0                	test   %eax,%eax
  801df9:	78 0e                	js     801e09 <read+0xd6>
			return m;
		if (m == 0)
  801dfb:	85 c0                	test   %eax,%eax
  801dfd:	74 08                	je     801e07 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801dff:	01 c3                	add    %eax,%ebx
  801e01:	89 da                	mov    %ebx,%edx
  801e03:	39 f3                	cmp    %esi,%ebx
  801e05:	72 c5                	jb     801dcc <read+0x99>
  801e07:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801e09:	83 c4 2c             	add    $0x2c,%esp
  801e0c:	5b                   	pop    %ebx
  801e0d:	5e                   	pop    %esi
  801e0e:	5f                   	pop    %edi
  801e0f:	5d                   	pop    %ebp
  801e10:	c3                   	ret    

00801e11 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801e11:	55                   	push   %ebp
  801e12:	89 e5                	mov    %esp,%ebp
  801e14:	57                   	push   %edi
  801e15:	56                   	push   %esi
  801e16:	53                   	push   %ebx
  801e17:	83 ec 1c             	sub    $0x1c,%esp
  801e1a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801e1d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801e20:	ba 00 00 00 00       	mov    $0x0,%edx
  801e25:	bb 00 00 00 00       	mov    $0x0,%ebx
  801e2a:	b8 00 00 00 00       	mov    $0x0,%eax
  801e2f:	85 f6                	test   %esi,%esi
  801e31:	74 29                	je     801e5c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801e33:	89 f0                	mov    %esi,%eax
  801e35:	29 d0                	sub    %edx,%eax
  801e37:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e3b:	03 55 0c             	add    0xc(%ebp),%edx
  801e3e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e42:	89 3c 24             	mov    %edi,(%esp)
  801e45:	e8 e9 fe ff ff       	call   801d33 <read>
		if (m < 0)
  801e4a:	85 c0                	test   %eax,%eax
  801e4c:	78 0e                	js     801e5c <readn+0x4b>
			return m;
		if (m == 0)
  801e4e:	85 c0                	test   %eax,%eax
  801e50:	74 08                	je     801e5a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801e52:	01 c3                	add    %eax,%ebx
  801e54:	89 da                	mov    %ebx,%edx
  801e56:	39 f3                	cmp    %esi,%ebx
  801e58:	72 d9                	jb     801e33 <readn+0x22>
  801e5a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801e5c:	83 c4 1c             	add    $0x1c,%esp
  801e5f:	5b                   	pop    %ebx
  801e60:	5e                   	pop    %esi
  801e61:	5f                   	pop    %edi
  801e62:	5d                   	pop    %ebp
  801e63:	c3                   	ret    

00801e64 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801e64:	55                   	push   %ebp
  801e65:	89 e5                	mov    %esp,%ebp
  801e67:	83 ec 28             	sub    $0x28,%esp
  801e6a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801e6d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801e70:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801e73:	89 34 24             	mov    %esi,(%esp)
  801e76:	e8 b5 fb ff ff       	call   801a30 <fd2num>
  801e7b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801e7e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e82:	89 04 24             	mov    %eax,(%esp)
  801e85:	e8 43 fc ff ff       	call   801acd <fd_lookup>
  801e8a:	89 c3                	mov    %eax,%ebx
  801e8c:	85 c0                	test   %eax,%eax
  801e8e:	78 05                	js     801e95 <fd_close+0x31>
  801e90:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801e93:	74 0e                	je     801ea3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801e95:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801e99:	b8 00 00 00 00       	mov    $0x0,%eax
  801e9e:	0f 44 d8             	cmove  %eax,%ebx
  801ea1:	eb 3d                	jmp    801ee0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801ea3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801ea6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eaa:	8b 06                	mov    (%esi),%eax
  801eac:	89 04 24             	mov    %eax,(%esp)
  801eaf:	e8 8d fc ff ff       	call   801b41 <dev_lookup>
  801eb4:	89 c3                	mov    %eax,%ebx
  801eb6:	85 c0                	test   %eax,%eax
  801eb8:	78 16                	js     801ed0 <fd_close+0x6c>
		if (dev->dev_close)
  801eba:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801ebd:	8b 40 10             	mov    0x10(%eax),%eax
  801ec0:	bb 00 00 00 00       	mov    $0x0,%ebx
  801ec5:	85 c0                	test   %eax,%eax
  801ec7:	74 07                	je     801ed0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801ec9:	89 34 24             	mov    %esi,(%esp)
  801ecc:	ff d0                	call   *%eax
  801ece:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801ed0:	89 74 24 04          	mov    %esi,0x4(%esp)
  801ed4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801edb:	e8 6a f5 ff ff       	call   80144a <sys_page_unmap>
	return r;
}
  801ee0:	89 d8                	mov    %ebx,%eax
  801ee2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801ee5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801ee8:	89 ec                	mov    %ebp,%esp
  801eea:	5d                   	pop    %ebp
  801eeb:	c3                   	ret    

00801eec <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801eec:	55                   	push   %ebp
  801eed:	89 e5                	mov    %esp,%ebp
  801eef:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801ef2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ef5:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ef9:	8b 45 08             	mov    0x8(%ebp),%eax
  801efc:	89 04 24             	mov    %eax,(%esp)
  801eff:	e8 c9 fb ff ff       	call   801acd <fd_lookup>
  801f04:	85 c0                	test   %eax,%eax
  801f06:	78 13                	js     801f1b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801f08:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801f0f:	00 
  801f10:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f13:	89 04 24             	mov    %eax,(%esp)
  801f16:	e8 49 ff ff ff       	call   801e64 <fd_close>
}
  801f1b:	c9                   	leave  
  801f1c:	c3                   	ret    

00801f1d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801f1d:	55                   	push   %ebp
  801f1e:	89 e5                	mov    %esp,%ebp
  801f20:	83 ec 18             	sub    $0x18,%esp
  801f23:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801f26:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801f29:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801f30:	00 
  801f31:	8b 45 08             	mov    0x8(%ebp),%eax
  801f34:	89 04 24             	mov    %eax,(%esp)
  801f37:	e8 80 03 00 00       	call   8022bc <open>
  801f3c:	89 c3                	mov    %eax,%ebx
  801f3e:	85 c0                	test   %eax,%eax
  801f40:	78 1b                	js     801f5d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801f42:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f45:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f49:	89 1c 24             	mov    %ebx,(%esp)
  801f4c:	e8 5e fc ff ff       	call   801baf <fstat>
  801f51:	89 c6                	mov    %eax,%esi
	close(fd);
  801f53:	89 1c 24             	mov    %ebx,(%esp)
  801f56:	e8 91 ff ff ff       	call   801eec <close>
  801f5b:	89 f3                	mov    %esi,%ebx
	return r;
}
  801f5d:	89 d8                	mov    %ebx,%eax
  801f5f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801f62:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801f65:	89 ec                	mov    %ebp,%esp
  801f67:	5d                   	pop    %ebp
  801f68:	c3                   	ret    

00801f69 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801f69:	55                   	push   %ebp
  801f6a:	89 e5                	mov    %esp,%ebp
  801f6c:	53                   	push   %ebx
  801f6d:	83 ec 14             	sub    $0x14,%esp
  801f70:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801f75:	89 1c 24             	mov    %ebx,(%esp)
  801f78:	e8 6f ff ff ff       	call   801eec <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801f7d:	83 c3 01             	add    $0x1,%ebx
  801f80:	83 fb 20             	cmp    $0x20,%ebx
  801f83:	75 f0                	jne    801f75 <close_all+0xc>
		close(i);
}
  801f85:	83 c4 14             	add    $0x14,%esp
  801f88:	5b                   	pop    %ebx
  801f89:	5d                   	pop    %ebp
  801f8a:	c3                   	ret    

00801f8b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801f8b:	55                   	push   %ebp
  801f8c:	89 e5                	mov    %esp,%ebp
  801f8e:	83 ec 58             	sub    $0x58,%esp
  801f91:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801f94:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801f97:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801f9a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801f9d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801fa0:	89 44 24 04          	mov    %eax,0x4(%esp)
  801fa4:	8b 45 08             	mov    0x8(%ebp),%eax
  801fa7:	89 04 24             	mov    %eax,(%esp)
  801faa:	e8 1e fb ff ff       	call   801acd <fd_lookup>
  801faf:	89 c3                	mov    %eax,%ebx
  801fb1:	85 c0                	test   %eax,%eax
  801fb3:	0f 88 e0 00 00 00    	js     802099 <dup+0x10e>
		return r;
	close(newfdnum);
  801fb9:	89 3c 24             	mov    %edi,(%esp)
  801fbc:	e8 2b ff ff ff       	call   801eec <close>

	newfd = INDEX2FD(newfdnum);
  801fc1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801fc7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801fca:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801fcd:	89 04 24             	mov    %eax,(%esp)
  801fd0:	e8 6b fa ff ff       	call   801a40 <fd2data>
  801fd5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801fd7:	89 34 24             	mov    %esi,(%esp)
  801fda:	e8 61 fa ff ff       	call   801a40 <fd2data>
  801fdf:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801fe2:	89 da                	mov    %ebx,%edx
  801fe4:	89 d8                	mov    %ebx,%eax
  801fe6:	c1 e8 16             	shr    $0x16,%eax
  801fe9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801ff0:	a8 01                	test   $0x1,%al
  801ff2:	74 43                	je     802037 <dup+0xac>
  801ff4:	c1 ea 0c             	shr    $0xc,%edx
  801ff7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801ffe:	a8 01                	test   $0x1,%al
  802000:	74 35                	je     802037 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  802002:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  802009:	25 07 0e 00 00       	and    $0xe07,%eax
  80200e:	89 44 24 10          	mov    %eax,0x10(%esp)
  802012:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  802015:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802019:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  802020:	00 
  802021:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802025:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80202c:	e8 77 f4 ff ff       	call   8014a8 <sys_page_map>
  802031:	89 c3                	mov    %eax,%ebx
  802033:	85 c0                	test   %eax,%eax
  802035:	78 3f                	js     802076 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  802037:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80203a:	89 c2                	mov    %eax,%edx
  80203c:	c1 ea 0c             	shr    $0xc,%edx
  80203f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  802046:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80204c:	89 54 24 10          	mov    %edx,0x10(%esp)
  802050:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802054:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80205b:	00 
  80205c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802060:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802067:	e8 3c f4 ff ff       	call   8014a8 <sys_page_map>
  80206c:	89 c3                	mov    %eax,%ebx
  80206e:	85 c0                	test   %eax,%eax
  802070:	78 04                	js     802076 <dup+0xeb>
  802072:	89 fb                	mov    %edi,%ebx
  802074:	eb 23                	jmp    802099 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  802076:	89 74 24 04          	mov    %esi,0x4(%esp)
  80207a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802081:	e8 c4 f3 ff ff       	call   80144a <sys_page_unmap>
	sys_page_unmap(0, nva);
  802086:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  802089:	89 44 24 04          	mov    %eax,0x4(%esp)
  80208d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802094:	e8 b1 f3 ff ff       	call   80144a <sys_page_unmap>
	return r;
}
  802099:	89 d8                	mov    %ebx,%eax
  80209b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80209e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8020a1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8020a4:	89 ec                	mov    %ebp,%esp
  8020a6:	5d                   	pop    %ebp
  8020a7:	c3                   	ret    

008020a8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  8020a8:	55                   	push   %ebp
  8020a9:	89 e5                	mov    %esp,%ebp
  8020ab:	53                   	push   %ebx
  8020ac:	83 ec 14             	sub    $0x14,%esp
  8020af:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  8020b1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  8020b7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8020be:	00 
  8020bf:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  8020c6:	00 
  8020c7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020cb:	89 14 24             	mov    %edx,(%esp)
  8020ce:	e8 6d 12 00 00       	call   803340 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8020d3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8020da:	00 
  8020db:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8020df:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8020e6:	e8 c7 12 00 00       	call   8033b2 <ipc_recv>
}
  8020eb:	83 c4 14             	add    $0x14,%esp
  8020ee:	5b                   	pop    %ebx
  8020ef:	5d                   	pop    %ebp
  8020f0:	c3                   	ret    

008020f1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  8020f1:	55                   	push   %ebp
  8020f2:	89 e5                	mov    %esp,%ebp
  8020f4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  8020f7:	8b 45 08             	mov    0x8(%ebp),%eax
  8020fa:	8b 40 0c             	mov    0xc(%eax),%eax
  8020fd:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  802102:	8b 45 0c             	mov    0xc(%ebp),%eax
  802105:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  80210a:	ba 00 00 00 00       	mov    $0x0,%edx
  80210f:	b8 02 00 00 00       	mov    $0x2,%eax
  802114:	e8 8f ff ff ff       	call   8020a8 <fsipc>
}
  802119:	c9                   	leave  
  80211a:	c3                   	ret    

0080211b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  80211b:	55                   	push   %ebp
  80211c:	89 e5                	mov    %esp,%ebp
  80211e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  802121:	8b 45 08             	mov    0x8(%ebp),%eax
  802124:	8b 40 0c             	mov    0xc(%eax),%eax
  802127:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  80212c:	ba 00 00 00 00       	mov    $0x0,%edx
  802131:	b8 06 00 00 00       	mov    $0x6,%eax
  802136:	e8 6d ff ff ff       	call   8020a8 <fsipc>
}
  80213b:	c9                   	leave  
  80213c:	c3                   	ret    

0080213d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80213d:	55                   	push   %ebp
  80213e:	89 e5                	mov    %esp,%ebp
  802140:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  802143:	ba 00 00 00 00       	mov    $0x0,%edx
  802148:	b8 08 00 00 00       	mov    $0x8,%eax
  80214d:	e8 56 ff ff ff       	call   8020a8 <fsipc>
}
  802152:	c9                   	leave  
  802153:	c3                   	ret    

00802154 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  802154:	55                   	push   %ebp
  802155:	89 e5                	mov    %esp,%ebp
  802157:	53                   	push   %ebx
  802158:	83 ec 14             	sub    $0x14,%esp
  80215b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80215e:	8b 45 08             	mov    0x8(%ebp),%eax
  802161:	8b 40 0c             	mov    0xc(%eax),%eax
  802164:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  802169:	ba 00 00 00 00       	mov    $0x0,%edx
  80216e:	b8 05 00 00 00       	mov    $0x5,%eax
  802173:	e8 30 ff ff ff       	call   8020a8 <fsipc>
  802178:	85 c0                	test   %eax,%eax
  80217a:	78 2b                	js     8021a7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80217c:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  802183:	00 
  802184:	89 1c 24             	mov    %ebx,(%esp)
  802187:	e8 1e ec ff ff       	call   800daa <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  80218c:	a1 80 40 80 00       	mov    0x804080,%eax
  802191:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  802197:	a1 84 40 80 00       	mov    0x804084,%eax
  80219c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  8021a2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8021a7:	83 c4 14             	add    $0x14,%esp
  8021aa:	5b                   	pop    %ebx
  8021ab:	5d                   	pop    %ebp
  8021ac:	c3                   	ret    

008021ad <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  8021ad:	55                   	push   %ebp
  8021ae:	89 e5                	mov    %esp,%ebp
  8021b0:	53                   	push   %ebx
  8021b1:	83 ec 14             	sub    $0x14,%esp
  8021b4:	8b 45 08             	mov    0x8(%ebp),%eax
  8021b7:	8b 55 0c             	mov    0xc(%ebp),%edx
  8021ba:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  8021bd:	85 c0                	test   %eax,%eax
  8021bf:	74 44                	je     802205 <devfile_write+0x58>
  8021c1:	85 d2                	test   %edx,%edx
  8021c3:	74 40                	je     802205 <devfile_write+0x58>
  8021c5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  8021cb:	77 38                	ja     802205 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  8021cd:	8b 40 0c             	mov    0xc(%eax),%eax
  8021d0:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  8021d5:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  8021db:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8021df:	89 54 24 04          	mov    %edx,0x4(%esp)
  8021e3:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  8021ea:	e8 76 ed ff ff       	call   800f65 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  8021ef:	ba 00 00 00 00       	mov    $0x0,%edx
  8021f4:	b8 04 00 00 00       	mov    $0x4,%eax
  8021f9:	e8 aa fe ff ff       	call   8020a8 <fsipc>
        return r;
    return n;
  8021fe:	85 c0                	test   %eax,%eax
  802200:	0f 49 c3             	cmovns %ebx,%eax
  802203:	eb 05                	jmp    80220a <devfile_write+0x5d>
  802205:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  80220a:	83 c4 14             	add    $0x14,%esp
  80220d:	5b                   	pop    %ebx
  80220e:	5d                   	pop    %ebp
  80220f:	c3                   	ret    

00802210 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  802210:	55                   	push   %ebp
  802211:	89 e5                	mov    %esp,%ebp
  802213:	83 ec 18             	sub    $0x18,%esp
  802216:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802219:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80221c:	8b 45 08             	mov    0x8(%ebp),%eax
  80221f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  802222:	85 c0                	test   %eax,%eax
  802224:	74 04                	je     80222a <devfile_read+0x1a>
  802226:	85 f6                	test   %esi,%esi
  802228:	75 07                	jne    802231 <devfile_read+0x21>
  80222a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  80222f:	eb 39                	jmp    80226a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  802231:	8b 40 0c             	mov    0xc(%eax),%eax
  802234:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  802239:	8b 45 10             	mov    0x10(%ebp),%eax
  80223c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  802241:	ba 00 00 00 00       	mov    $0x0,%edx
  802246:	b8 03 00 00 00       	mov    $0x3,%eax
  80224b:	e8 58 fe ff ff       	call   8020a8 <fsipc>
  802250:	89 c3                	mov    %eax,%ebx
  802252:	85 c0                	test   %eax,%eax
  802254:	78 14                	js     80226a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  802256:	89 44 24 08          	mov    %eax,0x8(%esp)
  80225a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  802261:	00 
  802262:	89 34 24             	mov    %esi,(%esp)
  802265:	e8 fb ec ff ff       	call   800f65 <memmove>
  return r;
}
  80226a:	89 d8                	mov    %ebx,%eax
  80226c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80226f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802272:	89 ec                	mov    %ebp,%esp
  802274:	5d                   	pop    %ebp
  802275:	c3                   	ret    

00802276 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  802276:	55                   	push   %ebp
  802277:	89 e5                	mov    %esp,%ebp
  802279:	53                   	push   %ebx
  80227a:	83 ec 14             	sub    $0x14,%esp
  80227d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  802280:	89 1c 24             	mov    %ebx,(%esp)
  802283:	e8 d8 ea ff ff       	call   800d60 <strlen>
  802288:	89 c2                	mov    %eax,%edx
  80228a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  80228f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  802295:	7f 1f                	jg     8022b6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  802297:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80229b:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  8022a2:	e8 03 eb ff ff       	call   800daa <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  8022a7:	ba 00 00 00 00       	mov    $0x0,%edx
  8022ac:	b8 07 00 00 00       	mov    $0x7,%eax
  8022b1:	e8 f2 fd ff ff       	call   8020a8 <fsipc>
}
  8022b6:	83 c4 14             	add    $0x14,%esp
  8022b9:	5b                   	pop    %ebx
  8022ba:	5d                   	pop    %ebp
  8022bb:	c3                   	ret    

008022bc <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  8022bc:	55                   	push   %ebp
  8022bd:	89 e5                	mov    %esp,%ebp
  8022bf:	83 ec 28             	sub    $0x28,%esp
  8022c2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8022c5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8022c8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  8022cb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  8022d0:	85 f6                	test   %esi,%esi
  8022d2:	74 65                	je     802339 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  8022d4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  8022db:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8022de:	89 04 24             	mov    %eax,(%esp)
  8022e1:	e8 75 f7 ff ff       	call   801a5b <fd_alloc>
  8022e6:	89 c3                	mov    %eax,%ebx
  8022e8:	85 c0                	test   %eax,%eax
  8022ea:	78 4d                	js     802339 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  8022ec:	89 74 24 04          	mov    %esi,0x4(%esp)
  8022f0:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  8022f7:	e8 ae ea ff ff       	call   800daa <strcpy>
	fsipcbuf.open.req_omode = mode;
  8022fc:	8b 45 0c             	mov    0xc(%ebp),%eax
  8022ff:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  802304:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802307:	b8 01 00 00 00       	mov    $0x1,%eax
  80230c:	e8 97 fd ff ff       	call   8020a8 <fsipc>
  802311:	89 c3                	mov    %eax,%ebx
  802313:	85 c0                	test   %eax,%eax
  802315:	79 15                	jns    80232c <open+0x70>
    fd_close(f, 0);
  802317:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80231e:	00 
  80231f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802322:	89 04 24             	mov    %eax,(%esp)
  802325:	e8 3a fb ff ff       	call   801e64 <fd_close>
    return r;
  80232a:	eb 0d                	jmp    802339 <open+0x7d>
  }
  return fd2num(f);
  80232c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80232f:	89 04 24             	mov    %eax,(%esp)
  802332:	e8 f9 f6 ff ff       	call   801a30 <fd2num>
  802337:	89 c3                	mov    %eax,%ebx
}
  802339:	89 d8                	mov    %ebx,%eax
  80233b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80233e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802341:	89 ec                	mov    %ebp,%esp
  802343:	5d                   	pop    %ebp
  802344:	c3                   	ret    
  802345:	00 00                	add    %al,(%eax)
	...

00802348 <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  802348:	55                   	push   %ebp
  802349:	89 e5                	mov    %esp,%ebp
  80234b:	57                   	push   %edi
  80234c:	56                   	push   %esi
  80234d:	53                   	push   %ebx
  80234e:	81 ec 9c 02 00 00    	sub    $0x29c,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  802354:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80235b:	00 
  80235c:	8b 45 08             	mov    0x8(%ebp),%eax
  80235f:	89 04 24             	mov    %eax,(%esp)
  802362:	e8 55 ff ff ff       	call   8022bc <open>
  802367:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
  80236d:	89 c3                	mov    %eax,%ebx
  80236f:	85 c0                	test   %eax,%eax
  802371:	0f 88 e0 05 00 00    	js     802957 <spawn+0x60f>
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
	    || elf->e_magic != ELF_MAGIC) {
  802377:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  80237e:	00 
  80237f:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  802385:	89 44 24 04          	mov    %eax,0x4(%esp)
  802389:	89 1c 24             	mov    %ebx,(%esp)
  80238c:	e8 a2 f9 ff ff       	call   801d33 <read>
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  802391:	3d 00 02 00 00       	cmp    $0x200,%eax
  802396:	75 0c                	jne    8023a4 <spawn+0x5c>
	    || elf->e_magic != ELF_MAGIC) {
  802398:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  80239f:	45 4c 46 
  8023a2:	74 36                	je     8023da <spawn+0x92>
		close(fd);
  8023a4:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  8023aa:	89 04 24             	mov    %eax,(%esp)
  8023ad:	e8 3a fb ff ff       	call   801eec <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  8023b2:	c7 44 24 08 7f 45 4c 	movl   $0x464c457f,0x8(%esp)
  8023b9:	46 
  8023ba:	8b 85 e8 fd ff ff    	mov    -0x218(%ebp),%eax
  8023c0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023c4:	c7 04 24 08 3e 80 00 	movl   $0x803e08,(%esp)
  8023cb:	e8 05 e3 ff ff       	call   8006d5 <cprintf>
  8023d0:	bb f2 ff ff ff       	mov    $0xfffffff2,%ebx
		return -E_NOT_EXEC;
  8023d5:	e9 7d 05 00 00       	jmp    802957 <spawn+0x60f>
  8023da:	ba 07 00 00 00       	mov    $0x7,%edx
  8023df:	89 d0                	mov    %edx,%eax
  8023e1:	cd 30                	int    $0x30
  8023e3:	89 85 84 fd ff ff    	mov    %eax,-0x27c(%ebp)
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  8023e9:	85 c0                	test   %eax,%eax
  8023eb:	0f 88 60 05 00 00    	js     802951 <spawn+0x609>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  8023f1:	89 c6                	mov    %eax,%esi
  8023f3:	81 e6 ff 03 00 00    	and    $0x3ff,%esi
  8023f9:	6b f6 7c             	imul   $0x7c,%esi,%esi
  8023fc:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  802402:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  802408:	b9 11 00 00 00       	mov    $0x11,%ecx
  80240d:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  80240f:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  802415:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  80241b:	8b 55 0c             	mov    0xc(%ebp),%edx
  80241e:	8b 02                	mov    (%edx),%eax
  802420:	bb 00 00 00 00       	mov    $0x0,%ebx
  802425:	be 00 00 00 00       	mov    $0x0,%esi
  80242a:	85 c0                	test   %eax,%eax
  80242c:	75 16                	jne    802444 <spawn+0xfc>
  80242e:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  802435:	00 00 00 
  802438:	c7 85 78 fd ff ff 00 	movl   $0x0,-0x288(%ebp)
  80243f:	00 00 00 
  802442:	eb 2c                	jmp    802470 <spawn+0x128>
  802444:	8b 7d 0c             	mov    0xc(%ebp),%edi
		string_size += strlen(argv[argc]) + 1;
  802447:	89 04 24             	mov    %eax,(%esp)
  80244a:	e8 11 e9 ff ff       	call   800d60 <strlen>
  80244f:	8d 5c 18 01          	lea    0x1(%eax,%ebx,1),%ebx
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  802453:	83 c6 01             	add    $0x1,%esi
  802456:	8d 14 b5 00 00 00 00 	lea    0x0(,%esi,4),%edx
  80245d:	8b 04 b7             	mov    (%edi,%esi,4),%eax
  802460:	85 c0                	test   %eax,%eax
  802462:	75 e3                	jne    802447 <spawn+0xff>
  802464:	89 95 7c fd ff ff    	mov    %edx,-0x284(%ebp)
  80246a:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  802470:	f7 db                	neg    %ebx
  802472:	8d bb 00 10 40 00    	lea    0x401000(%ebx),%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  802478:	89 fa                	mov    %edi,%edx
  80247a:	83 e2 fc             	and    $0xfffffffc,%edx
  80247d:	89 f0                	mov    %esi,%eax
  80247f:	f7 d0                	not    %eax
  802481:	8d 04 82             	lea    (%edx,%eax,4),%eax
  802484:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  80248a:	83 e8 08             	sub    $0x8,%eax
  80248d:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
	return child;

error:
	sys_env_destroy(child);
	close(fd);
	return r;
  802493:	bb fc ff ff ff       	mov    $0xfffffffc,%ebx
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  802498:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  80249d:	0f 86 b4 04 00 00    	jbe    802957 <spawn+0x60f>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  8024a3:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8024aa:	00 
  8024ab:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8024b2:	00 
  8024b3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024ba:	e8 47 f0 ff ff       	call   801506 <sys_page_alloc>
  8024bf:	89 c3                	mov    %eax,%ebx
  8024c1:	85 c0                	test   %eax,%eax
  8024c3:	0f 88 8e 04 00 00    	js     802957 <spawn+0x60f>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  8024c9:	85 f6                	test   %esi,%esi
  8024cb:	7e 46                	jle    802513 <spawn+0x1cb>
  8024cd:	bb 00 00 00 00       	mov    $0x0,%ebx
  8024d2:	89 b5 8c fd ff ff    	mov    %esi,-0x274(%ebp)
  8024d8:	8b 75 0c             	mov    0xc(%ebp),%esi
		argv_store[i] = UTEMP2USTACK(string_store);
  8024db:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  8024e1:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  8024e7:	89 04 9a             	mov    %eax,(%edx,%ebx,4)
		strcpy(string_store, argv[i]);
  8024ea:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  8024ed:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024f1:	89 3c 24             	mov    %edi,(%esp)
  8024f4:	e8 b1 e8 ff ff       	call   800daa <strcpy>
		string_store += strlen(argv[i]) + 1;
  8024f9:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  8024fc:	89 04 24             	mov    %eax,(%esp)
  8024ff:	e8 5c e8 ff ff       	call   800d60 <strlen>
  802504:	8d 7c 38 01          	lea    0x1(%eax,%edi,1),%edi
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  802508:	83 c3 01             	add    $0x1,%ebx
  80250b:	3b 9d 8c fd ff ff    	cmp    -0x274(%ebp),%ebx
  802511:	7c c8                	jl     8024db <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
		strcpy(string_store, argv[i]);
		string_store += strlen(argv[i]) + 1;
	}
	argv_store[argc] = 0;
  802513:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802519:	8b 85 7c fd ff ff    	mov    -0x284(%ebp),%eax
  80251f:	c7 04 02 00 00 00 00 	movl   $0x0,(%edx,%eax,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  802526:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  80252c:	74 24                	je     802552 <spawn+0x20a>
  80252e:	c7 44 24 0c a8 3e 80 	movl   $0x803ea8,0xc(%esp)
  802535:	00 
  802536:	c7 44 24 08 22 3e 80 	movl   $0x803e22,0x8(%esp)
  80253d:	00 
  80253e:	c7 44 24 04 d9 00 00 	movl   $0xd9,0x4(%esp)
  802545:	00 
  802546:	c7 04 24 37 3e 80 00 	movl   $0x803e37,(%esp)
  80254d:	e8 be e0 ff ff       	call   800610 <_panic>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  802552:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  802558:	2d 00 30 80 11       	sub    $0x11803000,%eax
  80255d:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802563:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  802566:	8b 95 78 fd ff ff    	mov    -0x288(%ebp),%edx
  80256c:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  802572:	89 10                	mov    %edx,(%eax)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  802574:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  80257a:	2d 08 30 80 11       	sub    $0x11803008,%eax
  80257f:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  802585:	c7 44 24 10 07 00 00 	movl   $0x7,0x10(%esp)
  80258c:	00 
  80258d:	c7 44 24 0c 00 d0 bf 	movl   $0xeebfd000,0xc(%esp)
  802594:	ee 
  802595:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  80259b:	89 44 24 08          	mov    %eax,0x8(%esp)
  80259f:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8025a6:	00 
  8025a7:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025ae:	e8 f5 ee ff ff       	call   8014a8 <sys_page_map>
  8025b3:	89 c3                	mov    %eax,%ebx
  8025b5:	85 c0                	test   %eax,%eax
  8025b7:	78 1a                	js     8025d3 <spawn+0x28b>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  8025b9:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8025c0:	00 
  8025c1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025c8:	e8 7d ee ff ff       	call   80144a <sys_page_unmap>
  8025cd:	89 c3                	mov    %eax,%ebx
  8025cf:	85 c0                	test   %eax,%eax
  8025d1:	79 19                	jns    8025ec <spawn+0x2a4>
		goto error;

	return 0;

error:
	sys_page_unmap(0, UTEMP);
  8025d3:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8025da:	00 
  8025db:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025e2:	e8 63 ee ff ff       	call   80144a <sys_page_unmap>
  8025e7:	e9 6b 03 00 00       	jmp    802957 <spawn+0x60f>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  8025ec:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  8025f2:	66 83 bd 14 fe ff ff 	cmpw   $0x0,-0x1ec(%ebp)
  8025f9:	00 
  8025fa:	0f 84 e4 01 00 00    	je     8027e4 <spawn+0x49c>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  802600:	8d 84 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%eax
  802607:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
  80260d:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  802614:	00 00 00 
	for (i = 0; i < elf->e_phnum; i++, ph++) {
		if (ph->p_type != ELF_PROG_LOAD)
  802617:	8b 95 80 fd ff ff    	mov    -0x280(%ebp),%edx
  80261d:	83 3a 01             	cmpl   $0x1,(%edx)
  802620:	0f 85 9c 01 00 00    	jne    8027c2 <spawn+0x47a>
			continue;
		perm = PTE_P | PTE_U;
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  802626:	8b 42 18             	mov    0x18(%edx),%eax
  802629:	83 e0 02             	and    $0x2,%eax
  80262c:	83 f8 01             	cmp    $0x1,%eax
  80262f:	19 c0                	sbb    %eax,%eax
  802631:	83 e0 fe             	and    $0xfffffffe,%eax
  802634:	83 c0 07             	add    $0x7,%eax
  802637:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
  80263d:	8b 52 04             	mov    0x4(%edx),%edx
  802640:	89 95 78 fd ff ff    	mov    %edx,-0x288(%ebp)
  802646:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  80264c:	8b 58 10             	mov    0x10(%eax),%ebx
  80264f:	8b 50 14             	mov    0x14(%eax),%edx
  802652:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
  802658:	8b 40 08             	mov    0x8(%eax),%eax
  80265b:	89 85 90 fd ff ff    	mov    %eax,-0x270(%ebp)
	int i, r;
	void *blk;

	//cprintf("map_segment %x+%x\n", va, memsz);

	if ((i = PGOFF(va))) {
  802661:	25 ff 0f 00 00       	and    $0xfff,%eax
  802666:	74 16                	je     80267e <spawn+0x336>
		va -= i;
  802668:	29 85 90 fd ff ff    	sub    %eax,-0x270(%ebp)
		memsz += i;
  80266e:	01 c2                	add    %eax,%edx
  802670:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
		filesz += i;
  802676:	01 c3                	add    %eax,%ebx
		fileoffset -= i;
  802678:	29 85 78 fd ff ff    	sub    %eax,-0x288(%ebp)
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  80267e:	83 bd 8c fd ff ff 00 	cmpl   $0x0,-0x274(%ebp)
  802685:	0f 84 37 01 00 00    	je     8027c2 <spawn+0x47a>
  80268b:	bf 00 00 00 00       	mov    $0x0,%edi
  802690:	be 00 00 00 00       	mov    $0x0,%esi
		if (i >= filesz) {
  802695:	39 fb                	cmp    %edi,%ebx
  802697:	77 31                	ja     8026ca <spawn+0x382>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  802699:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  80269f:	89 54 24 08          	mov    %edx,0x8(%esp)
  8026a3:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  8026a9:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8026ad:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  8026b3:	89 04 24             	mov    %eax,(%esp)
  8026b6:	e8 4b ee ff ff       	call   801506 <sys_page_alloc>
  8026bb:	85 c0                	test   %eax,%eax
  8026bd:	0f 89 eb 00 00 00    	jns    8027ae <spawn+0x466>
  8026c3:	89 c3                	mov    %eax,%ebx
  8026c5:	e9 69 02 00 00       	jmp    802933 <spawn+0x5eb>
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  8026ca:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8026d1:	00 
  8026d2:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8026d9:	00 
  8026da:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026e1:	e8 20 ee ff ff       	call   801506 <sys_page_alloc>
  8026e6:	85 c0                	test   %eax,%eax
  8026e8:	0f 88 3b 02 00 00    	js     802929 <spawn+0x5e1>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  8026ee:	8b 85 78 fd ff ff    	mov    -0x288(%ebp),%eax
  8026f4:	8d 04 06             	lea    (%esi,%eax,1),%eax
  8026f7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026fb:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802701:	89 14 24             	mov    %edx,(%esp)
  802704:	e8 0c f4 ff ff       	call   801b15 <seek>
  802709:	85 c0                	test   %eax,%eax
  80270b:	0f 88 1c 02 00 00    	js     80292d <spawn+0x5e5>
				return r;
			if ((r = read(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  802711:	89 d8                	mov    %ebx,%eax
  802713:	29 f8                	sub    %edi,%eax
  802715:	3d 00 10 00 00       	cmp    $0x1000,%eax
  80271a:	ba 00 10 00 00       	mov    $0x1000,%edx
  80271f:	0f 47 c2             	cmova  %edx,%eax
  802722:	89 44 24 08          	mov    %eax,0x8(%esp)
  802726:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  80272d:	00 
  80272e:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  802734:	89 04 24             	mov    %eax,(%esp)
  802737:	e8 f7 f5 ff ff       	call   801d33 <read>
  80273c:	85 c0                	test   %eax,%eax
  80273e:	0f 88 ed 01 00 00    	js     802931 <spawn+0x5e9>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  802744:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  80274a:	89 54 24 10          	mov    %edx,0x10(%esp)
  80274e:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  802754:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  802758:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  80275e:	89 44 24 08          	mov    %eax,0x8(%esp)
  802762:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  802769:	00 
  80276a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802771:	e8 32 ed ff ff       	call   8014a8 <sys_page_map>
  802776:	85 c0                	test   %eax,%eax
  802778:	79 20                	jns    80279a <spawn+0x452>
				panic("spawn: sys_page_map data: %e", r);
  80277a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80277e:	c7 44 24 08 43 3e 80 	movl   $0x803e43,0x8(%esp)
  802785:	00 
  802786:	c7 44 24 04 0c 01 00 	movl   $0x10c,0x4(%esp)
  80278d:	00 
  80278e:	c7 04 24 37 3e 80 00 	movl   $0x803e37,(%esp)
  802795:	e8 76 de ff ff       	call   800610 <_panic>
			sys_page_unmap(0, UTEMP);
  80279a:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  8027a1:	00 
  8027a2:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8027a9:	e8 9c ec ff ff       	call   80144a <sys_page_unmap>
		memsz += i;
		filesz += i;
		fileoffset -= i;
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  8027ae:	81 c6 00 10 00 00    	add    $0x1000,%esi
  8027b4:	89 f7                	mov    %esi,%edi
  8027b6:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  8027bc:	0f 87 d3 fe ff ff    	ja     802695 <spawn+0x34d>
	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  8027c2:	83 85 7c fd ff ff 01 	addl   $0x1,-0x284(%ebp)
  8027c9:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  8027d0:	3b 85 7c fd ff ff    	cmp    -0x284(%ebp),%eax
  8027d6:	7e 0c                	jle    8027e4 <spawn+0x49c>
  8027d8:	83 85 80 fd ff ff 20 	addl   $0x20,-0x280(%ebp)
  8027df:	e9 33 fe ff ff       	jmp    802617 <spawn+0x2cf>
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
				     fd, ph->p_filesz, ph->p_offset, perm)) < 0)
			goto error;
	}
	close(fd);
  8027e4:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  8027ea:	89 14 24             	mov    %edx,(%esp)
  8027ed:	e8 fa f6 ff ff       	call   801eec <close>
static int
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
  8027f2:	e8 a2 ed ff ff       	call   801599 <sys_getenvid>
  8027f7:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  8027fd:	b8 00 00 00 00       	mov    $0x0,%eax
  802802:	bb 00 00 00 00       	mov    $0x0,%ebx
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
        if (((vpd[PDX(va)] & PTE_P) && (vpt[VPN(va)] & PTE_P) && (vpt[VPN(va)] & PTE_SHARE))) {
  802807:	be 00 d0 7b ef       	mov    $0xef7bd000,%esi
  80280c:	bf 00 00 40 ef       	mov    $0xef400000,%edi
  802811:	89 c2                	mov    %eax,%edx
  802813:	89 d1                	mov    %edx,%ecx
  802815:	c1 e9 16             	shr    $0x16,%ecx
  802818:	8b 0c 8e             	mov    (%esi,%ecx,4),%ecx
  80281b:	f6 c1 01             	test   $0x1,%cl
  80281e:	74 5f                	je     80287f <spawn+0x537>
  802820:	c1 ea 0c             	shr    $0xc,%edx
  802823:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  802826:	f6 c1 01             	test   $0x1,%cl
  802829:	74 54                	je     80287f <spawn+0x537>
  80282b:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  80282e:	f6 c5 04             	test   $0x4,%ch
  802831:	74 4c                	je     80287f <spawn+0x537>
            if((r=sys_page_map(cur, (void *)(va), child, (void *)(va), vpt[VPN(va)]&PTE_USER))<0)
  802833:	8b 04 97             	mov    (%edi,%edx,4),%eax
  802836:	25 07 0e 00 00       	and    $0xe07,%eax
  80283b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80283f:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  802843:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802849:	89 44 24 08          	mov    %eax,0x8(%esp)
  80284d:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802851:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802857:	89 14 24             	mov    %edx,(%esp)
  80285a:	e8 49 ec ff ff       	call   8014a8 <sys_page_map>
  80285f:	85 c0                	test   %eax,%eax
  802861:	79 1c                	jns    80287f <spawn+0x537>
                panic("copy_shared_pages: error sharing\n");
  802863:	c7 44 24 08 d0 3e 80 	movl   $0x803ed0,0x8(%esp)
  80286a:	00 
  80286b:	c7 44 24 04 1d 01 00 	movl   $0x11d,0x4(%esp)
  802872:	00 
  802873:	c7 04 24 37 3e 80 00 	movl   $0x803e37,(%esp)
  80287a:	e8 91 dd ff ff       	call   800610 <_panic>
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
  80287f:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  802885:	89 da                	mov    %ebx,%edx
  802887:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  80288d:	75 84                	jne    802813 <spawn+0x4cb>
	}
	close(fd);
	fd = -1;

	// Copy shared library state.
	if ((r = copy_shared_pages(child)) < 0)
  80288f:	85 c0                	test   %eax,%eax
  802891:	79 20                	jns    8028b3 <spawn+0x56b>
		panic("copy_shared_pages: %e", r);
  802893:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802897:	c7 44 24 08 60 3e 80 	movl   $0x803e60,0x8(%esp)
  80289e:	00 
  80289f:	c7 44 24 04 82 00 00 	movl   $0x82,0x4(%esp)
  8028a6:	00 
  8028a7:	c7 04 24 37 3e 80 00 	movl   $0x803e37,(%esp)
  8028ae:	e8 5d dd ff ff       	call   800610 <_panic>

	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  8028b3:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  8028b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028bd:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  8028c3:	89 04 24             	mov    %eax,(%esp)
  8028c6:	e8 c3 ea ff ff       	call   80138e <sys_env_set_trapframe>
  8028cb:	85 c0                	test   %eax,%eax
  8028cd:	79 20                	jns    8028ef <spawn+0x5a7>
		panic("sys_env_set_trapframe: %e", r);
  8028cf:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8028d3:	c7 44 24 08 76 3e 80 	movl   $0x803e76,0x8(%esp)
  8028da:	00 
  8028db:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  8028e2:	00 
  8028e3:	c7 04 24 37 3e 80 00 	movl   $0x803e37,(%esp)
  8028ea:	e8 21 dd ff ff       	call   800610 <_panic>

	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  8028ef:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8028f6:	00 
  8028f7:	8b 95 84 fd ff ff    	mov    -0x27c(%ebp),%edx
  8028fd:	89 14 24             	mov    %edx,(%esp)
  802900:	e8 e7 ea ff ff       	call   8013ec <sys_env_set_status>
  802905:	85 c0                	test   %eax,%eax
  802907:	79 48                	jns    802951 <spawn+0x609>
		panic("sys_env_set_status: %e", r);
  802909:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80290d:	c7 44 24 08 90 3e 80 	movl   $0x803e90,0x8(%esp)
  802914:	00 
  802915:	c7 44 24 04 88 00 00 	movl   $0x88,0x4(%esp)
  80291c:	00 
  80291d:	c7 04 24 37 3e 80 00 	movl   $0x803e37,(%esp)
  802924:	e8 e7 dc ff ff       	call   800610 <_panic>
  802929:	89 c3                	mov    %eax,%ebx
  80292b:	eb 06                	jmp    802933 <spawn+0x5eb>
  80292d:	89 c3                	mov    %eax,%ebx
  80292f:	eb 02                	jmp    802933 <spawn+0x5eb>
  802931:	89 c3                	mov    %eax,%ebx

	return child;

error:
	sys_env_destroy(child);
  802933:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802939:	89 04 24             	mov    %eax,(%esp)
  80293c:	e8 8c ec ff ff       	call   8015cd <sys_env_destroy>
	close(fd);
  802941:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  802947:	89 14 24             	mov    %edx,(%esp)
  80294a:	e8 9d f5 ff ff       	call   801eec <close>
	return r;
  80294f:	eb 06                	jmp    802957 <spawn+0x60f>
  802951:	8b 9d 84 fd ff ff    	mov    -0x27c(%ebp),%ebx
}
  802957:	89 d8                	mov    %ebx,%eax
  802959:	81 c4 9c 02 00 00    	add    $0x29c,%esp
  80295f:	5b                   	pop    %ebx
  802960:	5e                   	pop    %esi
  802961:	5f                   	pop    %edi
  802962:	5d                   	pop    %ebp
  802963:	c3                   	ret    

00802964 <spawnl>:

// Spawn, taking command-line arguments array directly on the stack.
int
spawnl(const char *prog, const char *arg0, ...)
{
  802964:	55                   	push   %ebp
  802965:	89 e5                	mov    %esp,%ebp
  802967:	83 ec 18             	sub    $0x18,%esp
	return spawn(prog, &arg0);
  80296a:	8d 45 0c             	lea    0xc(%ebp),%eax
  80296d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802971:	8b 45 08             	mov    0x8(%ebp),%eax
  802974:	89 04 24             	mov    %eax,(%esp)
  802977:	e8 cc f9 ff ff       	call   802348 <spawn>
}
  80297c:	c9                   	leave  
  80297d:	c3                   	ret    
	...

00802980 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  802980:	55                   	push   %ebp
  802981:	89 e5                	mov    %esp,%ebp
  802983:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  802986:	c7 44 24 04 f2 3e 80 	movl   $0x803ef2,0x4(%esp)
  80298d:	00 
  80298e:	8b 45 0c             	mov    0xc(%ebp),%eax
  802991:	89 04 24             	mov    %eax,(%esp)
  802994:	e8 11 e4 ff ff       	call   800daa <strcpy>
	return 0;
}
  802999:	b8 00 00 00 00       	mov    $0x0,%eax
  80299e:	c9                   	leave  
  80299f:	c3                   	ret    

008029a0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  8029a0:	55                   	push   %ebp
  8029a1:	89 e5                	mov    %esp,%ebp
  8029a3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  8029a6:	8b 45 08             	mov    0x8(%ebp),%eax
  8029a9:	8b 40 0c             	mov    0xc(%eax),%eax
  8029ac:	89 04 24             	mov    %eax,(%esp)
  8029af:	e8 9d 02 00 00       	call   802c51 <nsipc_close>
}
  8029b4:	c9                   	leave  
  8029b5:	c3                   	ret    

008029b6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8029b6:	55                   	push   %ebp
  8029b7:	89 e5                	mov    %esp,%ebp
  8029b9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8029bc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8029c3:	00 
  8029c4:	8b 45 10             	mov    0x10(%ebp),%eax
  8029c7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8029cb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029ce:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029d2:	8b 45 08             	mov    0x8(%ebp),%eax
  8029d5:	8b 40 0c             	mov    0xc(%eax),%eax
  8029d8:	89 04 24             	mov    %eax,(%esp)
  8029db:	e8 ad 02 00 00       	call   802c8d <nsipc_send>
}
  8029e0:	c9                   	leave  
  8029e1:	c3                   	ret    

008029e2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  8029e2:	55                   	push   %ebp
  8029e3:	89 e5                	mov    %esp,%ebp
  8029e5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  8029e8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8029ef:	00 
  8029f0:	8b 45 10             	mov    0x10(%ebp),%eax
  8029f3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8029f7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8029fa:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029fe:	8b 45 08             	mov    0x8(%ebp),%eax
  802a01:	8b 40 0c             	mov    0xc(%eax),%eax
  802a04:	89 04 24             	mov    %eax,(%esp)
  802a07:	e8 f4 02 00 00       	call   802d00 <nsipc_recv>
}
  802a0c:	c9                   	leave  
  802a0d:	c3                   	ret    

00802a0e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  802a0e:	55                   	push   %ebp
  802a0f:	89 e5                	mov    %esp,%ebp
  802a11:	56                   	push   %esi
  802a12:	53                   	push   %ebx
  802a13:	83 ec 20             	sub    $0x20,%esp
  802a16:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802a18:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802a1b:	89 04 24             	mov    %eax,(%esp)
  802a1e:	e8 38 f0 ff ff       	call   801a5b <fd_alloc>
  802a23:	89 c3                	mov    %eax,%ebx
  802a25:	85 c0                	test   %eax,%eax
  802a27:	78 21                	js     802a4a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802a29:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802a30:	00 
  802a31:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a34:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a38:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a3f:	e8 c2 ea ff ff       	call   801506 <sys_page_alloc>
  802a44:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802a46:	85 c0                	test   %eax,%eax
  802a48:	79 0a                	jns    802a54 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  802a4a:	89 34 24             	mov    %esi,(%esp)
  802a4d:	e8 ff 01 00 00       	call   802c51 <nsipc_close>
		return r;
  802a52:	eb 28                	jmp    802a7c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802a54:	8b 15 3c 70 80 00    	mov    0x80703c,%edx
  802a5a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a5d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  802a5f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a62:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  802a69:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a6c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  802a6f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a72:	89 04 24             	mov    %eax,(%esp)
  802a75:	e8 b6 ef ff ff       	call   801a30 <fd2num>
  802a7a:	89 c3                	mov    %eax,%ebx
}
  802a7c:	89 d8                	mov    %ebx,%eax
  802a7e:	83 c4 20             	add    $0x20,%esp
  802a81:	5b                   	pop    %ebx
  802a82:	5e                   	pop    %esi
  802a83:	5d                   	pop    %ebp
  802a84:	c3                   	ret    

00802a85 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  802a85:	55                   	push   %ebp
  802a86:	89 e5                	mov    %esp,%ebp
  802a88:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  802a8b:	8b 45 10             	mov    0x10(%ebp),%eax
  802a8e:	89 44 24 08          	mov    %eax,0x8(%esp)
  802a92:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a95:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a99:	8b 45 08             	mov    0x8(%ebp),%eax
  802a9c:	89 04 24             	mov    %eax,(%esp)
  802a9f:	e8 61 01 00 00       	call   802c05 <nsipc_socket>
  802aa4:	85 c0                	test   %eax,%eax
  802aa6:	78 05                	js     802aad <socket+0x28>
		return r;
	return alloc_sockfd(r);
  802aa8:	e8 61 ff ff ff       	call   802a0e <alloc_sockfd>
}
  802aad:	c9                   	leave  
  802aae:	66 90                	xchg   %ax,%ax
  802ab0:	c3                   	ret    

00802ab1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  802ab1:	55                   	push   %ebp
  802ab2:	89 e5                	mov    %esp,%ebp
  802ab4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  802ab7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  802aba:	89 54 24 04          	mov    %edx,0x4(%esp)
  802abe:	89 04 24             	mov    %eax,(%esp)
  802ac1:	e8 07 f0 ff ff       	call   801acd <fd_lookup>
  802ac6:	85 c0                	test   %eax,%eax
  802ac8:	78 15                	js     802adf <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  802aca:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802acd:	8b 0a                	mov    (%edx),%ecx
  802acf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802ad4:	3b 0d 3c 70 80 00    	cmp    0x80703c,%ecx
  802ada:	75 03                	jne    802adf <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  802adc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  802adf:	c9                   	leave  
  802ae0:	c3                   	ret    

00802ae1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802ae1:	55                   	push   %ebp
  802ae2:	89 e5                	mov    %esp,%ebp
  802ae4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802ae7:	8b 45 08             	mov    0x8(%ebp),%eax
  802aea:	e8 c2 ff ff ff       	call   802ab1 <fd2sockid>
  802aef:	85 c0                	test   %eax,%eax
  802af1:	78 0f                	js     802b02 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  802af3:	8b 55 0c             	mov    0xc(%ebp),%edx
  802af6:	89 54 24 04          	mov    %edx,0x4(%esp)
  802afa:	89 04 24             	mov    %eax,(%esp)
  802afd:	e8 2d 01 00 00       	call   802c2f <nsipc_listen>
}
  802b02:	c9                   	leave  
  802b03:	c3                   	ret    

00802b04 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802b04:	55                   	push   %ebp
  802b05:	89 e5                	mov    %esp,%ebp
  802b07:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802b0a:	8b 45 08             	mov    0x8(%ebp),%eax
  802b0d:	e8 9f ff ff ff       	call   802ab1 <fd2sockid>
  802b12:	85 c0                	test   %eax,%eax
  802b14:	78 16                	js     802b2c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802b16:	8b 55 10             	mov    0x10(%ebp),%edx
  802b19:	89 54 24 08          	mov    %edx,0x8(%esp)
  802b1d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802b20:	89 54 24 04          	mov    %edx,0x4(%esp)
  802b24:	89 04 24             	mov    %eax,(%esp)
  802b27:	e8 54 02 00 00       	call   802d80 <nsipc_connect>
}
  802b2c:	c9                   	leave  
  802b2d:	c3                   	ret    

00802b2e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  802b2e:	55                   	push   %ebp
  802b2f:	89 e5                	mov    %esp,%ebp
  802b31:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802b34:	8b 45 08             	mov    0x8(%ebp),%eax
  802b37:	e8 75 ff ff ff       	call   802ab1 <fd2sockid>
  802b3c:	85 c0                	test   %eax,%eax
  802b3e:	78 0f                	js     802b4f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802b40:	8b 55 0c             	mov    0xc(%ebp),%edx
  802b43:	89 54 24 04          	mov    %edx,0x4(%esp)
  802b47:	89 04 24             	mov    %eax,(%esp)
  802b4a:	e8 1c 01 00 00       	call   802c6b <nsipc_shutdown>
}
  802b4f:	c9                   	leave  
  802b50:	c3                   	ret    

00802b51 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802b51:	55                   	push   %ebp
  802b52:	89 e5                	mov    %esp,%ebp
  802b54:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802b57:	8b 45 08             	mov    0x8(%ebp),%eax
  802b5a:	e8 52 ff ff ff       	call   802ab1 <fd2sockid>
  802b5f:	85 c0                	test   %eax,%eax
  802b61:	78 16                	js     802b79 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802b63:	8b 55 10             	mov    0x10(%ebp),%edx
  802b66:	89 54 24 08          	mov    %edx,0x8(%esp)
  802b6a:	8b 55 0c             	mov    0xc(%ebp),%edx
  802b6d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802b71:	89 04 24             	mov    %eax,(%esp)
  802b74:	e8 46 02 00 00       	call   802dbf <nsipc_bind>
}
  802b79:	c9                   	leave  
  802b7a:	c3                   	ret    

00802b7b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  802b7b:	55                   	push   %ebp
  802b7c:	89 e5                	mov    %esp,%ebp
  802b7e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802b81:	8b 45 08             	mov    0x8(%ebp),%eax
  802b84:	e8 28 ff ff ff       	call   802ab1 <fd2sockid>
  802b89:	85 c0                	test   %eax,%eax
  802b8b:	78 1f                	js     802bac <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  802b8d:	8b 55 10             	mov    0x10(%ebp),%edx
  802b90:	89 54 24 08          	mov    %edx,0x8(%esp)
  802b94:	8b 55 0c             	mov    0xc(%ebp),%edx
  802b97:	89 54 24 04          	mov    %edx,0x4(%esp)
  802b9b:	89 04 24             	mov    %eax,(%esp)
  802b9e:	e8 5b 02 00 00       	call   802dfe <nsipc_accept>
  802ba3:	85 c0                	test   %eax,%eax
  802ba5:	78 05                	js     802bac <accept+0x31>
		return r;
	return alloc_sockfd(r);
  802ba7:	e8 62 fe ff ff       	call   802a0e <alloc_sockfd>
}
  802bac:	c9                   	leave  
  802bad:	8d 76 00             	lea    0x0(%esi),%esi
  802bb0:	c3                   	ret    
	...

00802bc0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  802bc0:	55                   	push   %ebp
  802bc1:	89 e5                	mov    %esp,%ebp
  802bc3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  802bc6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  802bcc:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  802bd3:	00 
  802bd4:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  802bdb:	00 
  802bdc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802be0:	89 14 24             	mov    %edx,(%esp)
  802be3:	e8 58 07 00 00       	call   803340 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802be8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  802bef:	00 
  802bf0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  802bf7:	00 
  802bf8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802bfb:	89 04 24             	mov    %eax,(%esp)
  802bfe:	e8 af 07 00 00       	call   8033b2 <ipc_recv>
    return r;
}
  802c03:	c9                   	leave  
  802c04:	c3                   	ret    

00802c05 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  802c05:	55                   	push   %ebp
  802c06:	89 e5                	mov    %esp,%ebp
  802c08:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  802c0b:	8b 45 08             	mov    0x8(%ebp),%eax
  802c0e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802c13:	8b 45 0c             	mov    0xc(%ebp),%eax
  802c16:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  802c1b:	8b 45 10             	mov    0x10(%ebp),%eax
  802c1e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802c23:	b8 09 00 00 00       	mov    $0x9,%eax
  802c28:	e8 93 ff ff ff       	call   802bc0 <nsipc>
}
  802c2d:	c9                   	leave  
  802c2e:	c3                   	ret    

00802c2f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  802c2f:	55                   	push   %ebp
  802c30:	89 e5                	mov    %esp,%ebp
  802c32:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802c35:	8b 45 08             	mov    0x8(%ebp),%eax
  802c38:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  802c3d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802c40:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802c45:	b8 06 00 00 00       	mov    $0x6,%eax
  802c4a:	e8 71 ff ff ff       	call   802bc0 <nsipc>
}
  802c4f:	c9                   	leave  
  802c50:	c3                   	ret    

00802c51 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802c51:	55                   	push   %ebp
  802c52:	89 e5                	mov    %esp,%ebp
  802c54:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802c57:	8b 45 08             	mov    0x8(%ebp),%eax
  802c5a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  802c5f:	b8 04 00 00 00       	mov    $0x4,%eax
  802c64:	e8 57 ff ff ff       	call   802bc0 <nsipc>
}
  802c69:	c9                   	leave  
  802c6a:	c3                   	ret    

00802c6b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  802c6b:	55                   	push   %ebp
  802c6c:	89 e5                	mov    %esp,%ebp
  802c6e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802c71:	8b 45 08             	mov    0x8(%ebp),%eax
  802c74:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802c79:	8b 45 0c             	mov    0xc(%ebp),%eax
  802c7c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  802c81:	b8 03 00 00 00       	mov    $0x3,%eax
  802c86:	e8 35 ff ff ff       	call   802bc0 <nsipc>
}
  802c8b:	c9                   	leave  
  802c8c:	c3                   	ret    

00802c8d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  802c8d:	55                   	push   %ebp
  802c8e:	89 e5                	mov    %esp,%ebp
  802c90:	53                   	push   %ebx
  802c91:	83 ec 14             	sub    $0x14,%esp
  802c94:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  802c97:	8b 45 08             	mov    0x8(%ebp),%eax
  802c9a:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  802c9f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  802ca5:	7e 24                	jle    802ccb <nsipc_send+0x3e>
  802ca7:	c7 44 24 0c fe 3e 80 	movl   $0x803efe,0xc(%esp)
  802cae:	00 
  802caf:	c7 44 24 08 22 3e 80 	movl   $0x803e22,0x8(%esp)
  802cb6:	00 
  802cb7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  802cbe:	00 
  802cbf:	c7 04 24 0a 3f 80 00 	movl   $0x803f0a,(%esp)
  802cc6:	e8 45 d9 ff ff       	call   800610 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  802ccb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802ccf:	8b 45 0c             	mov    0xc(%ebp),%eax
  802cd2:	89 44 24 04          	mov    %eax,0x4(%esp)
  802cd6:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  802cdd:	e8 83 e2 ff ff       	call   800f65 <memmove>
	nsipcbuf.send.req_size = size;
  802ce2:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802ce8:	8b 45 14             	mov    0x14(%ebp),%eax
  802ceb:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  802cf0:	b8 08 00 00 00       	mov    $0x8,%eax
  802cf5:	e8 c6 fe ff ff       	call   802bc0 <nsipc>
}
  802cfa:	83 c4 14             	add    $0x14,%esp
  802cfd:	5b                   	pop    %ebx
  802cfe:	5d                   	pop    %ebp
  802cff:	c3                   	ret    

00802d00 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802d00:	55                   	push   %ebp
  802d01:	89 e5                	mov    %esp,%ebp
  802d03:	56                   	push   %esi
  802d04:	53                   	push   %ebx
  802d05:	83 ec 10             	sub    $0x10,%esp
  802d08:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  802d0b:	8b 45 08             	mov    0x8(%ebp),%eax
  802d0e:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802d13:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802d19:	8b 45 14             	mov    0x14(%ebp),%eax
  802d1c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802d21:	b8 07 00 00 00       	mov    $0x7,%eax
  802d26:	e8 95 fe ff ff       	call   802bc0 <nsipc>
  802d2b:	89 c3                	mov    %eax,%ebx
  802d2d:	85 c0                	test   %eax,%eax
  802d2f:	78 46                	js     802d77 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802d31:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802d36:	7f 04                	jg     802d3c <nsipc_recv+0x3c>
  802d38:	39 c6                	cmp    %eax,%esi
  802d3a:	7d 24                	jge    802d60 <nsipc_recv+0x60>
  802d3c:	c7 44 24 0c 16 3f 80 	movl   $0x803f16,0xc(%esp)
  802d43:	00 
  802d44:	c7 44 24 08 22 3e 80 	movl   $0x803e22,0x8(%esp)
  802d4b:	00 
  802d4c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802d53:	00 
  802d54:	c7 04 24 0a 3f 80 00 	movl   $0x803f0a,(%esp)
  802d5b:	e8 b0 d8 ff ff       	call   800610 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802d60:	89 44 24 08          	mov    %eax,0x8(%esp)
  802d64:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802d6b:	00 
  802d6c:	8b 45 0c             	mov    0xc(%ebp),%eax
  802d6f:	89 04 24             	mov    %eax,(%esp)
  802d72:	e8 ee e1 ff ff       	call   800f65 <memmove>
	}

	return r;
}
  802d77:	89 d8                	mov    %ebx,%eax
  802d79:	83 c4 10             	add    $0x10,%esp
  802d7c:	5b                   	pop    %ebx
  802d7d:	5e                   	pop    %esi
  802d7e:	5d                   	pop    %ebp
  802d7f:	c3                   	ret    

00802d80 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802d80:	55                   	push   %ebp
  802d81:	89 e5                	mov    %esp,%ebp
  802d83:	53                   	push   %ebx
  802d84:	83 ec 14             	sub    $0x14,%esp
  802d87:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  802d8a:	8b 45 08             	mov    0x8(%ebp),%eax
  802d8d:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802d92:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802d96:	8b 45 0c             	mov    0xc(%ebp),%eax
  802d99:	89 44 24 04          	mov    %eax,0x4(%esp)
  802d9d:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802da4:	e8 bc e1 ff ff       	call   800f65 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802da9:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  802daf:	b8 05 00 00 00       	mov    $0x5,%eax
  802db4:	e8 07 fe ff ff       	call   802bc0 <nsipc>
}
  802db9:	83 c4 14             	add    $0x14,%esp
  802dbc:	5b                   	pop    %ebx
  802dbd:	5d                   	pop    %ebp
  802dbe:	c3                   	ret    

00802dbf <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802dbf:	55                   	push   %ebp
  802dc0:	89 e5                	mov    %esp,%ebp
  802dc2:	53                   	push   %ebx
  802dc3:	83 ec 14             	sub    $0x14,%esp
  802dc6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802dc9:	8b 45 08             	mov    0x8(%ebp),%eax
  802dcc:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  802dd1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802dd5:	8b 45 0c             	mov    0xc(%ebp),%eax
  802dd8:	89 44 24 04          	mov    %eax,0x4(%esp)
  802ddc:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802de3:	e8 7d e1 ff ff       	call   800f65 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802de8:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  802dee:	b8 02 00 00 00       	mov    $0x2,%eax
  802df3:	e8 c8 fd ff ff       	call   802bc0 <nsipc>
}
  802df8:	83 c4 14             	add    $0x14,%esp
  802dfb:	5b                   	pop    %ebx
  802dfc:	5d                   	pop    %ebp
  802dfd:	c3                   	ret    

00802dfe <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  802dfe:	55                   	push   %ebp
  802dff:	89 e5                	mov    %esp,%ebp
  802e01:	83 ec 18             	sub    $0x18,%esp
  802e04:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802e07:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  802e0a:	8b 45 08             	mov    0x8(%ebp),%eax
  802e0d:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802e12:	b8 01 00 00 00       	mov    $0x1,%eax
  802e17:	e8 a4 fd ff ff       	call   802bc0 <nsipc>
  802e1c:	89 c3                	mov    %eax,%ebx
  802e1e:	85 c0                	test   %eax,%eax
  802e20:	78 25                	js     802e47 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802e22:	be 10 60 80 00       	mov    $0x806010,%esi
  802e27:	8b 06                	mov    (%esi),%eax
  802e29:	89 44 24 08          	mov    %eax,0x8(%esp)
  802e2d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802e34:	00 
  802e35:	8b 45 0c             	mov    0xc(%ebp),%eax
  802e38:	89 04 24             	mov    %eax,(%esp)
  802e3b:	e8 25 e1 ff ff       	call   800f65 <memmove>
		*addrlen = ret->ret_addrlen;
  802e40:	8b 16                	mov    (%esi),%edx
  802e42:	8b 45 10             	mov    0x10(%ebp),%eax
  802e45:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802e47:	89 d8                	mov    %ebx,%eax
  802e49:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802e4c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802e4f:	89 ec                	mov    %ebp,%esp
  802e51:	5d                   	pop    %ebp
  802e52:	c3                   	ret    
	...

00802e60 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802e60:	55                   	push   %ebp
  802e61:	89 e5                	mov    %esp,%ebp
  802e63:	83 ec 18             	sub    $0x18,%esp
  802e66:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802e69:	89 75 fc             	mov    %esi,-0x4(%ebp)
  802e6c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  802e6f:	8b 45 08             	mov    0x8(%ebp),%eax
  802e72:	89 04 24             	mov    %eax,(%esp)
  802e75:	e8 c6 eb ff ff       	call   801a40 <fd2data>
  802e7a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  802e7c:	c7 44 24 04 2b 3f 80 	movl   $0x803f2b,0x4(%esp)
  802e83:	00 
  802e84:	89 34 24             	mov    %esi,(%esp)
  802e87:	e8 1e df ff ff       	call   800daa <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  802e8c:	8b 43 04             	mov    0x4(%ebx),%eax
  802e8f:	2b 03                	sub    (%ebx),%eax
  802e91:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802e97:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  802e9e:	00 00 00 
	stat->st_dev = &devpipe;
  802ea1:	c7 86 88 00 00 00 58 	movl   $0x807058,0x88(%esi)
  802ea8:	70 80 00 
	return 0;
}
  802eab:	b8 00 00 00 00       	mov    $0x0,%eax
  802eb0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802eb3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802eb6:	89 ec                	mov    %ebp,%esp
  802eb8:	5d                   	pop    %ebp
  802eb9:	c3                   	ret    

00802eba <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  802eba:	55                   	push   %ebp
  802ebb:	89 e5                	mov    %esp,%ebp
  802ebd:	53                   	push   %ebx
  802ebe:	83 ec 14             	sub    $0x14,%esp
  802ec1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802ec4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802ec8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802ecf:	e8 76 e5 ff ff       	call   80144a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802ed4:	89 1c 24             	mov    %ebx,(%esp)
  802ed7:	e8 64 eb ff ff       	call   801a40 <fd2data>
  802edc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802ee0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802ee7:	e8 5e e5 ff ff       	call   80144a <sys_page_unmap>
}
  802eec:	83 c4 14             	add    $0x14,%esp
  802eef:	5b                   	pop    %ebx
  802ef0:	5d                   	pop    %ebp
  802ef1:	c3                   	ret    

00802ef2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802ef2:	55                   	push   %ebp
  802ef3:	89 e5                	mov    %esp,%ebp
  802ef5:	57                   	push   %edi
  802ef6:	56                   	push   %esi
  802ef7:	53                   	push   %ebx
  802ef8:	83 ec 2c             	sub    $0x2c,%esp
  802efb:	89 c7                	mov    %eax,%edi
  802efd:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802f00:	a1 74 70 80 00       	mov    0x807074,%eax
  802f05:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802f08:	89 3c 24             	mov    %edi,(%esp)
  802f0b:	e8 f4 04 00 00       	call   803404 <pageref>
  802f10:	89 c6                	mov    %eax,%esi
  802f12:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802f15:	89 04 24             	mov    %eax,(%esp)
  802f18:	e8 e7 04 00 00       	call   803404 <pageref>
  802f1d:	39 c6                	cmp    %eax,%esi
  802f1f:	0f 94 c0             	sete   %al
  802f22:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802f25:	8b 15 74 70 80 00    	mov    0x807074,%edx
  802f2b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  802f2e:	39 cb                	cmp    %ecx,%ebx
  802f30:	75 08                	jne    802f3a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802f32:	83 c4 2c             	add    $0x2c,%esp
  802f35:	5b                   	pop    %ebx
  802f36:	5e                   	pop    %esi
  802f37:	5f                   	pop    %edi
  802f38:	5d                   	pop    %ebp
  802f39:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  802f3a:	83 f8 01             	cmp    $0x1,%eax
  802f3d:	75 c1                	jne    802f00 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  802f3f:	8b 52 58             	mov    0x58(%edx),%edx
  802f42:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802f46:	89 54 24 08          	mov    %edx,0x8(%esp)
  802f4a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802f4e:	c7 04 24 32 3f 80 00 	movl   $0x803f32,(%esp)
  802f55:	e8 7b d7 ff ff       	call   8006d5 <cprintf>
  802f5a:	eb a4                	jmp    802f00 <_pipeisclosed+0xe>

00802f5c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802f5c:	55                   	push   %ebp
  802f5d:	89 e5                	mov    %esp,%ebp
  802f5f:	57                   	push   %edi
  802f60:	56                   	push   %esi
  802f61:	53                   	push   %ebx
  802f62:	83 ec 1c             	sub    $0x1c,%esp
  802f65:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802f68:	89 34 24             	mov    %esi,(%esp)
  802f6b:	e8 d0 ea ff ff       	call   801a40 <fd2data>
  802f70:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802f72:	bf 00 00 00 00       	mov    $0x0,%edi
  802f77:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802f7b:	75 54                	jne    802fd1 <devpipe_write+0x75>
  802f7d:	eb 60                	jmp    802fdf <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  802f7f:	89 da                	mov    %ebx,%edx
  802f81:	89 f0                	mov    %esi,%eax
  802f83:	e8 6a ff ff ff       	call   802ef2 <_pipeisclosed>
  802f88:	85 c0                	test   %eax,%eax
  802f8a:	74 07                	je     802f93 <devpipe_write+0x37>
  802f8c:	b8 00 00 00 00       	mov    $0x0,%eax
  802f91:	eb 53                	jmp    802fe6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802f93:	90                   	nop
  802f94:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f98:	e8 c8 e5 ff ff       	call   801565 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802f9d:	8b 43 04             	mov    0x4(%ebx),%eax
  802fa0:	8b 13                	mov    (%ebx),%edx
  802fa2:	83 c2 20             	add    $0x20,%edx
  802fa5:	39 d0                	cmp    %edx,%eax
  802fa7:	73 d6                	jae    802f7f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802fa9:	89 c2                	mov    %eax,%edx
  802fab:	c1 fa 1f             	sar    $0x1f,%edx
  802fae:	c1 ea 1b             	shr    $0x1b,%edx
  802fb1:	01 d0                	add    %edx,%eax
  802fb3:	83 e0 1f             	and    $0x1f,%eax
  802fb6:	29 d0                	sub    %edx,%eax
  802fb8:	89 c2                	mov    %eax,%edx
  802fba:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802fbd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802fc1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802fc5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802fc9:	83 c7 01             	add    $0x1,%edi
  802fcc:	39 7d 10             	cmp    %edi,0x10(%ebp)
  802fcf:	76 13                	jbe    802fe4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802fd1:	8b 43 04             	mov    0x4(%ebx),%eax
  802fd4:	8b 13                	mov    (%ebx),%edx
  802fd6:	83 c2 20             	add    $0x20,%edx
  802fd9:	39 d0                	cmp    %edx,%eax
  802fdb:	73 a2                	jae    802f7f <devpipe_write+0x23>
  802fdd:	eb ca                	jmp    802fa9 <devpipe_write+0x4d>
  802fdf:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802fe4:	89 f8                	mov    %edi,%eax
}
  802fe6:	83 c4 1c             	add    $0x1c,%esp
  802fe9:	5b                   	pop    %ebx
  802fea:	5e                   	pop    %esi
  802feb:	5f                   	pop    %edi
  802fec:	5d                   	pop    %ebp
  802fed:	c3                   	ret    

00802fee <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  802fee:	55                   	push   %ebp
  802fef:	89 e5                	mov    %esp,%ebp
  802ff1:	83 ec 28             	sub    $0x28,%esp
  802ff4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802ff7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802ffa:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802ffd:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  803000:	89 3c 24             	mov    %edi,(%esp)
  803003:	e8 38 ea ff ff       	call   801a40 <fd2data>
  803008:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80300a:	be 00 00 00 00       	mov    $0x0,%esi
  80300f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  803013:	75 4c                	jne    803061 <devpipe_read+0x73>
  803015:	eb 5b                	jmp    803072 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  803017:	89 f0                	mov    %esi,%eax
  803019:	eb 5e                	jmp    803079 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80301b:	89 da                	mov    %ebx,%edx
  80301d:	89 f8                	mov    %edi,%eax
  80301f:	90                   	nop
  803020:	e8 cd fe ff ff       	call   802ef2 <_pipeisclosed>
  803025:	85 c0                	test   %eax,%eax
  803027:	74 07                	je     803030 <devpipe_read+0x42>
  803029:	b8 00 00 00 00       	mov    $0x0,%eax
  80302e:	eb 49                	jmp    803079 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  803030:	e8 30 e5 ff ff       	call   801565 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  803035:	8b 03                	mov    (%ebx),%eax
  803037:	3b 43 04             	cmp    0x4(%ebx),%eax
  80303a:	74 df                	je     80301b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80303c:	89 c2                	mov    %eax,%edx
  80303e:	c1 fa 1f             	sar    $0x1f,%edx
  803041:	c1 ea 1b             	shr    $0x1b,%edx
  803044:	01 d0                	add    %edx,%eax
  803046:	83 e0 1f             	and    $0x1f,%eax
  803049:	29 d0                	sub    %edx,%eax
  80304b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  803050:	8b 55 0c             	mov    0xc(%ebp),%edx
  803053:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  803056:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  803059:	83 c6 01             	add    $0x1,%esi
  80305c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80305f:	76 16                	jbe    803077 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  803061:	8b 03                	mov    (%ebx),%eax
  803063:	3b 43 04             	cmp    0x4(%ebx),%eax
  803066:	75 d4                	jne    80303c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  803068:	85 f6                	test   %esi,%esi
  80306a:	75 ab                	jne    803017 <devpipe_read+0x29>
  80306c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803070:	eb a9                	jmp    80301b <devpipe_read+0x2d>
  803072:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  803077:	89 f0                	mov    %esi,%eax
}
  803079:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80307c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80307f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  803082:	89 ec                	mov    %ebp,%esp
  803084:	5d                   	pop    %ebp
  803085:	c3                   	ret    

00803086 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  803086:	55                   	push   %ebp
  803087:	89 e5                	mov    %esp,%ebp
  803089:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80308c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80308f:	89 44 24 04          	mov    %eax,0x4(%esp)
  803093:	8b 45 08             	mov    0x8(%ebp),%eax
  803096:	89 04 24             	mov    %eax,(%esp)
  803099:	e8 2f ea ff ff       	call   801acd <fd_lookup>
  80309e:	85 c0                	test   %eax,%eax
  8030a0:	78 15                	js     8030b7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  8030a2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8030a5:	89 04 24             	mov    %eax,(%esp)
  8030a8:	e8 93 e9 ff ff       	call   801a40 <fd2data>
	return _pipeisclosed(fd, p);
  8030ad:	89 c2                	mov    %eax,%edx
  8030af:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8030b2:	e8 3b fe ff ff       	call   802ef2 <_pipeisclosed>
}
  8030b7:	c9                   	leave  
  8030b8:	c3                   	ret    

008030b9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8030b9:	55                   	push   %ebp
  8030ba:	89 e5                	mov    %esp,%ebp
  8030bc:	83 ec 48             	sub    $0x48,%esp
  8030bf:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8030c2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8030c5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8030c8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8030cb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8030ce:	89 04 24             	mov    %eax,(%esp)
  8030d1:	e8 85 e9 ff ff       	call   801a5b <fd_alloc>
  8030d6:	89 c3                	mov    %eax,%ebx
  8030d8:	85 c0                	test   %eax,%eax
  8030da:	0f 88 42 01 00 00    	js     803222 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8030e0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8030e7:	00 
  8030e8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8030eb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8030ef:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8030f6:	e8 0b e4 ff ff       	call   801506 <sys_page_alloc>
  8030fb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8030fd:	85 c0                	test   %eax,%eax
  8030ff:	0f 88 1d 01 00 00    	js     803222 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  803105:	8d 45 e0             	lea    -0x20(%ebp),%eax
  803108:	89 04 24             	mov    %eax,(%esp)
  80310b:	e8 4b e9 ff ff       	call   801a5b <fd_alloc>
  803110:	89 c3                	mov    %eax,%ebx
  803112:	85 c0                	test   %eax,%eax
  803114:	0f 88 f5 00 00 00    	js     80320f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80311a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  803121:	00 
  803122:	8b 45 e0             	mov    -0x20(%ebp),%eax
  803125:	89 44 24 04          	mov    %eax,0x4(%esp)
  803129:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803130:	e8 d1 e3 ff ff       	call   801506 <sys_page_alloc>
  803135:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  803137:	85 c0                	test   %eax,%eax
  803139:	0f 88 d0 00 00 00    	js     80320f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80313f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  803142:	89 04 24             	mov    %eax,(%esp)
  803145:	e8 f6 e8 ff ff       	call   801a40 <fd2data>
  80314a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80314c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  803153:	00 
  803154:	89 44 24 04          	mov    %eax,0x4(%esp)
  803158:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80315f:	e8 a2 e3 ff ff       	call   801506 <sys_page_alloc>
  803164:	89 c3                	mov    %eax,%ebx
  803166:	85 c0                	test   %eax,%eax
  803168:	0f 88 8e 00 00 00    	js     8031fc <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80316e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  803171:	89 04 24             	mov    %eax,(%esp)
  803174:	e8 c7 e8 ff ff       	call   801a40 <fd2data>
  803179:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  803180:	00 
  803181:	89 44 24 0c          	mov    %eax,0xc(%esp)
  803185:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80318c:	00 
  80318d:	89 74 24 04          	mov    %esi,0x4(%esp)
  803191:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  803198:	e8 0b e3 ff ff       	call   8014a8 <sys_page_map>
  80319d:	89 c3                	mov    %eax,%ebx
  80319f:	85 c0                	test   %eax,%eax
  8031a1:	78 49                	js     8031ec <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  8031a3:	b8 58 70 80 00       	mov    $0x807058,%eax
  8031a8:	8b 08                	mov    (%eax),%ecx
  8031aa:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8031ad:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  8031af:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8031b2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8031b9:	8b 10                	mov    (%eax),%edx
  8031bb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8031be:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8031c0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8031c3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8031ca:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8031cd:	89 04 24             	mov    %eax,(%esp)
  8031d0:	e8 5b e8 ff ff       	call   801a30 <fd2num>
  8031d5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8031d7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8031da:	89 04 24             	mov    %eax,(%esp)
  8031dd:	e8 4e e8 ff ff       	call   801a30 <fd2num>
  8031e2:	89 47 04             	mov    %eax,0x4(%edi)
  8031e5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  8031ea:	eb 36                	jmp    803222 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  8031ec:	89 74 24 04          	mov    %esi,0x4(%esp)
  8031f0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8031f7:	e8 4e e2 ff ff       	call   80144a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8031fc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8031ff:	89 44 24 04          	mov    %eax,0x4(%esp)
  803203:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80320a:	e8 3b e2 ff ff       	call   80144a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  80320f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  803212:	89 44 24 04          	mov    %eax,0x4(%esp)
  803216:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80321d:	e8 28 e2 ff ff       	call   80144a <sys_page_unmap>
    err:
	return r;
}
  803222:	89 d8                	mov    %ebx,%eax
  803224:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  803227:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80322a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80322d:	89 ec                	mov    %ebp,%esp
  80322f:	5d                   	pop    %ebp
  803230:	c3                   	ret    
  803231:	00 00                	add    %al,(%eax)
	...

00803234 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  803234:	55                   	push   %ebp
  803235:	89 e5                	mov    %esp,%ebp
  803237:	56                   	push   %esi
  803238:	53                   	push   %ebx
  803239:	83 ec 10             	sub    $0x10,%esp
  80323c:	8b 45 08             	mov    0x8(%ebp),%eax
	volatile struct Env *e;

	assert(envid != 0);
  80323f:	85 c0                	test   %eax,%eax
  803241:	75 24                	jne    803267 <wait+0x33>
  803243:	c7 44 24 0c 4a 3f 80 	movl   $0x803f4a,0xc(%esp)
  80324a:	00 
  80324b:	c7 44 24 08 22 3e 80 	movl   $0x803e22,0x8(%esp)
  803252:	00 
  803253:	c7 44 24 04 09 00 00 	movl   $0x9,0x4(%esp)
  80325a:	00 
  80325b:	c7 04 24 55 3f 80 00 	movl   $0x803f55,(%esp)
  803262:	e8 a9 d3 ff ff       	call   800610 <_panic>
	e = &envs[ENVX(envid)];
  803267:	89 c3                	mov    %eax,%ebx
  803269:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
  80326f:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  803272:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  803278:	8b 73 4c             	mov    0x4c(%ebx),%esi
  80327b:	39 c6                	cmp    %eax,%esi
  80327d:	75 1a                	jne    803299 <wait+0x65>
  80327f:	8b 43 54             	mov    0x54(%ebx),%eax
  803282:	85 c0                	test   %eax,%eax
  803284:	74 13                	je     803299 <wait+0x65>
		sys_yield();
  803286:	e8 da e2 ff ff       	call   801565 <sys_yield>
{
	volatile struct Env *e;

	assert(envid != 0);
	e = &envs[ENVX(envid)];
	while (e->env_id == envid && e->env_status != ENV_FREE)
  80328b:	8b 43 4c             	mov    0x4c(%ebx),%eax
  80328e:	39 f0                	cmp    %esi,%eax
  803290:	75 07                	jne    803299 <wait+0x65>
  803292:	8b 43 54             	mov    0x54(%ebx),%eax
  803295:	85 c0                	test   %eax,%eax
  803297:	75 ed                	jne    803286 <wait+0x52>
		sys_yield();
}
  803299:	83 c4 10             	add    $0x10,%esp
  80329c:	5b                   	pop    %ebx
  80329d:	5e                   	pop    %esi
  80329e:	5d                   	pop    %ebp
  80329f:	c3                   	ret    

008032a0 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  8032a0:	55                   	push   %ebp
  8032a1:	89 e5                	mov    %esp,%ebp
  8032a3:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  8032a6:	83 3d 7c 70 80 00 00 	cmpl   $0x0,0x80707c
  8032ad:	75 55                	jne    803304 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  8032af:	e8 e5 e2 ff ff       	call   801599 <sys_getenvid>
  8032b4:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8032bb:	00 
  8032bc:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  8032c3:	ee 
  8032c4:	89 04 24             	mov    %eax,(%esp)
  8032c7:	e8 3a e2 ff ff       	call   801506 <sys_page_alloc>
  8032cc:	85 c0                	test   %eax,%eax
  8032ce:	74 1c                	je     8032ec <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  8032d0:	c7 44 24 08 60 3f 80 	movl   $0x803f60,0x8(%esp)
  8032d7:	00 
  8032d8:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  8032df:	00 
  8032e0:	c7 04 24 84 3f 80 00 	movl   $0x803f84,(%esp)
  8032e7:	e8 24 d3 ff ff       	call   800610 <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  8032ec:	a1 74 70 80 00       	mov    0x807074,%eax
  8032f1:	8b 40 4c             	mov    0x4c(%eax),%eax
  8032f4:	c7 44 24 04 10 33 80 	movl   $0x803310,0x4(%esp)
  8032fb:	00 
  8032fc:	89 04 24             	mov    %eax,(%esp)
  8032ff:	e8 2c e0 ff ff       	call   801330 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  803304:	8b 45 08             	mov    0x8(%ebp),%eax
  803307:	a3 7c 70 80 00       	mov    %eax,0x80707c
}
  80330c:	c9                   	leave  
  80330d:	c3                   	ret    
	...

00803310 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  803310:	54                   	push   %esp
	movl _pgfault_handler, %eax
  803311:	a1 7c 70 80 00       	mov    0x80707c,%eax
	call *%eax
  803316:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  803318:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  80331b:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  803320:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  803324:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  803328:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  80332a:	83 c4 08             	add    $0x8,%esp
    popal
  80332d:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  80332e:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  803332:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  803333:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  803337:	c3                   	ret    
	...

00803340 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  803340:	55                   	push   %ebp
  803341:	89 e5                	mov    %esp,%ebp
  803343:	57                   	push   %edi
  803344:	56                   	push   %esi
  803345:	53                   	push   %ebx
  803346:	83 ec 2c             	sub    $0x2c,%esp
  803349:	8b 75 08             	mov    0x8(%ebp),%esi
  80334c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80334f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  803352:	85 db                	test   %ebx,%ebx
  803354:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  803359:	0f 45 c3             	cmovne %ebx,%eax
  80335c:	8b 55 14             	mov    0x14(%ebp),%edx
  80335f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  803363:	89 44 24 08          	mov    %eax,0x8(%esp)
  803367:	89 7c 24 04          	mov    %edi,0x4(%esp)
  80336b:	89 34 24             	mov    %esi,(%esp)
  80336e:	e8 5d df ff ff       	call   8012d0 <sys_ipc_try_send>
  803373:	83 f8 f9             	cmp    $0xfffffff9,%eax
  803376:	75 0a                	jne    803382 <ipc_send+0x42>
      sys_yield();
  803378:	e8 e8 e1 ff ff       	call   801565 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80337d:	8d 76 00             	lea    0x0(%esi),%esi
  803380:	eb d0                	jmp    803352 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  803382:	85 c0                	test   %eax,%eax
  803384:	79 24                	jns    8033aa <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  803386:	89 44 24 10          	mov    %eax,0x10(%esp)
  80338a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80338e:	c7 44 24 08 94 3f 80 	movl   $0x803f94,0x8(%esp)
  803395:	00 
  803396:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80339d:	00 
  80339e:	c7 04 24 b8 3f 80 00 	movl   $0x803fb8,(%esp)
  8033a5:	e8 66 d2 ff ff       	call   800610 <_panic>
    else
      return;
  }
}
  8033aa:	83 c4 2c             	add    $0x2c,%esp
  8033ad:	5b                   	pop    %ebx
  8033ae:	5e                   	pop    %esi
  8033af:	5f                   	pop    %edi
  8033b0:	5d                   	pop    %ebp
  8033b1:	c3                   	ret    

008033b2 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  8033b2:	55                   	push   %ebp
  8033b3:	89 e5                	mov    %esp,%ebp
  8033b5:	56                   	push   %esi
  8033b6:	53                   	push   %ebx
  8033b7:	83 ec 10             	sub    $0x10,%esp
  8033ba:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8033bd:	8b 45 0c             	mov    0xc(%ebp),%eax
  8033c0:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  8033c3:	85 c0                	test   %eax,%eax
  8033c5:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  8033ca:	0f 44 c2             	cmove  %edx,%eax
  8033cd:	89 04 24             	mov    %eax,(%esp)
  8033d0:	e8 9e de ff ff       	call   801273 <sys_ipc_recv>
  8033d5:	85 c0                	test   %eax,%eax
  8033d7:	78 24                	js     8033fd <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  8033d9:	85 db                	test   %ebx,%ebx
  8033db:	74 0a                	je     8033e7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  8033dd:	a1 74 70 80 00       	mov    0x807074,%eax
  8033e2:	8b 40 74             	mov    0x74(%eax),%eax
  8033e5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  8033e7:	85 f6                	test   %esi,%esi
  8033e9:	74 0a                	je     8033f5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  8033eb:	a1 74 70 80 00       	mov    0x807074,%eax
  8033f0:	8b 40 78             	mov    0x78(%eax),%eax
  8033f3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  8033f5:	a1 74 70 80 00       	mov    0x807074,%eax
  8033fa:	8b 40 70             	mov    0x70(%eax),%eax
}
  8033fd:	83 c4 10             	add    $0x10,%esp
  803400:	5b                   	pop    %ebx
  803401:	5e                   	pop    %esi
  803402:	5d                   	pop    %ebp
  803403:	c3                   	ret    

00803404 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  803404:	55                   	push   %ebp
  803405:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  803407:	8b 45 08             	mov    0x8(%ebp),%eax
  80340a:	89 c2                	mov    %eax,%edx
  80340c:	c1 ea 16             	shr    $0x16,%edx
  80340f:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  803416:	f6 c2 01             	test   $0x1,%dl
  803419:	74 26                	je     803441 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  80341b:	c1 e8 0c             	shr    $0xc,%eax
  80341e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  803425:	a8 01                	test   $0x1,%al
  803427:	74 18                	je     803441 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  803429:	c1 e8 0c             	shr    $0xc,%eax
  80342c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  80342f:	c1 e2 02             	shl    $0x2,%edx
  803432:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  803437:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  80343c:	0f b7 c0             	movzwl %ax,%eax
  80343f:	eb 05                	jmp    803446 <pageref+0x42>
  803441:	b8 00 00 00 00       	mov    $0x0,%eax
}
  803446:	5d                   	pop    %ebp
  803447:	c3                   	ret    
	...

00803450 <__udivdi3>:
  803450:	55                   	push   %ebp
  803451:	89 e5                	mov    %esp,%ebp
  803453:	57                   	push   %edi
  803454:	56                   	push   %esi
  803455:	83 ec 10             	sub    $0x10,%esp
  803458:	8b 45 14             	mov    0x14(%ebp),%eax
  80345b:	8b 55 08             	mov    0x8(%ebp),%edx
  80345e:	8b 75 10             	mov    0x10(%ebp),%esi
  803461:	8b 7d 0c             	mov    0xc(%ebp),%edi
  803464:	85 c0                	test   %eax,%eax
  803466:	89 55 f0             	mov    %edx,-0x10(%ebp)
  803469:	75 35                	jne    8034a0 <__udivdi3+0x50>
  80346b:	39 fe                	cmp    %edi,%esi
  80346d:	77 61                	ja     8034d0 <__udivdi3+0x80>
  80346f:	85 f6                	test   %esi,%esi
  803471:	75 0b                	jne    80347e <__udivdi3+0x2e>
  803473:	b8 01 00 00 00       	mov    $0x1,%eax
  803478:	31 d2                	xor    %edx,%edx
  80347a:	f7 f6                	div    %esi
  80347c:	89 c6                	mov    %eax,%esi
  80347e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  803481:	31 d2                	xor    %edx,%edx
  803483:	89 f8                	mov    %edi,%eax
  803485:	f7 f6                	div    %esi
  803487:	89 c7                	mov    %eax,%edi
  803489:	89 c8                	mov    %ecx,%eax
  80348b:	f7 f6                	div    %esi
  80348d:	89 c1                	mov    %eax,%ecx
  80348f:	89 fa                	mov    %edi,%edx
  803491:	89 c8                	mov    %ecx,%eax
  803493:	83 c4 10             	add    $0x10,%esp
  803496:	5e                   	pop    %esi
  803497:	5f                   	pop    %edi
  803498:	5d                   	pop    %ebp
  803499:	c3                   	ret    
  80349a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  8034a0:	39 f8                	cmp    %edi,%eax
  8034a2:	77 1c                	ja     8034c0 <__udivdi3+0x70>
  8034a4:	0f bd d0             	bsr    %eax,%edx
  8034a7:	83 f2 1f             	xor    $0x1f,%edx
  8034aa:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8034ad:	75 39                	jne    8034e8 <__udivdi3+0x98>
  8034af:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  8034b2:	0f 86 a0 00 00 00    	jbe    803558 <__udivdi3+0x108>
  8034b8:	39 f8                	cmp    %edi,%eax
  8034ba:	0f 82 98 00 00 00    	jb     803558 <__udivdi3+0x108>
  8034c0:	31 ff                	xor    %edi,%edi
  8034c2:	31 c9                	xor    %ecx,%ecx
  8034c4:	89 c8                	mov    %ecx,%eax
  8034c6:	89 fa                	mov    %edi,%edx
  8034c8:	83 c4 10             	add    $0x10,%esp
  8034cb:	5e                   	pop    %esi
  8034cc:	5f                   	pop    %edi
  8034cd:	5d                   	pop    %ebp
  8034ce:	c3                   	ret    
  8034cf:	90                   	nop
  8034d0:	89 d1                	mov    %edx,%ecx
  8034d2:	89 fa                	mov    %edi,%edx
  8034d4:	89 c8                	mov    %ecx,%eax
  8034d6:	31 ff                	xor    %edi,%edi
  8034d8:	f7 f6                	div    %esi
  8034da:	89 c1                	mov    %eax,%ecx
  8034dc:	89 fa                	mov    %edi,%edx
  8034de:	89 c8                	mov    %ecx,%eax
  8034e0:	83 c4 10             	add    $0x10,%esp
  8034e3:	5e                   	pop    %esi
  8034e4:	5f                   	pop    %edi
  8034e5:	5d                   	pop    %ebp
  8034e6:	c3                   	ret    
  8034e7:	90                   	nop
  8034e8:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8034ec:	89 f2                	mov    %esi,%edx
  8034ee:	d3 e0                	shl    %cl,%eax
  8034f0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8034f3:	b8 20 00 00 00       	mov    $0x20,%eax
  8034f8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  8034fb:	89 c1                	mov    %eax,%ecx
  8034fd:	d3 ea                	shr    %cl,%edx
  8034ff:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  803503:	0b 55 ec             	or     -0x14(%ebp),%edx
  803506:	d3 e6                	shl    %cl,%esi
  803508:	89 c1                	mov    %eax,%ecx
  80350a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  80350d:	89 fe                	mov    %edi,%esi
  80350f:	d3 ee                	shr    %cl,%esi
  803511:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  803515:	89 55 ec             	mov    %edx,-0x14(%ebp)
  803518:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80351b:	d3 e7                	shl    %cl,%edi
  80351d:	89 c1                	mov    %eax,%ecx
  80351f:	d3 ea                	shr    %cl,%edx
  803521:	09 d7                	or     %edx,%edi
  803523:	89 f2                	mov    %esi,%edx
  803525:	89 f8                	mov    %edi,%eax
  803527:	f7 75 ec             	divl   -0x14(%ebp)
  80352a:	89 d6                	mov    %edx,%esi
  80352c:	89 c7                	mov    %eax,%edi
  80352e:	f7 65 e8             	mull   -0x18(%ebp)
  803531:	39 d6                	cmp    %edx,%esi
  803533:	89 55 ec             	mov    %edx,-0x14(%ebp)
  803536:	72 30                	jb     803568 <__udivdi3+0x118>
  803538:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80353b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80353f:	d3 e2                	shl    %cl,%edx
  803541:	39 c2                	cmp    %eax,%edx
  803543:	73 05                	jae    80354a <__udivdi3+0xfa>
  803545:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  803548:	74 1e                	je     803568 <__udivdi3+0x118>
  80354a:	89 f9                	mov    %edi,%ecx
  80354c:	31 ff                	xor    %edi,%edi
  80354e:	e9 71 ff ff ff       	jmp    8034c4 <__udivdi3+0x74>
  803553:	90                   	nop
  803554:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803558:	31 ff                	xor    %edi,%edi
  80355a:	b9 01 00 00 00       	mov    $0x1,%ecx
  80355f:	e9 60 ff ff ff       	jmp    8034c4 <__udivdi3+0x74>
  803564:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803568:	8d 4f ff             	lea    -0x1(%edi),%ecx
  80356b:	31 ff                	xor    %edi,%edi
  80356d:	89 c8                	mov    %ecx,%eax
  80356f:	89 fa                	mov    %edi,%edx
  803571:	83 c4 10             	add    $0x10,%esp
  803574:	5e                   	pop    %esi
  803575:	5f                   	pop    %edi
  803576:	5d                   	pop    %ebp
  803577:	c3                   	ret    
	...

00803580 <__umoddi3>:
  803580:	55                   	push   %ebp
  803581:	89 e5                	mov    %esp,%ebp
  803583:	57                   	push   %edi
  803584:	56                   	push   %esi
  803585:	83 ec 20             	sub    $0x20,%esp
  803588:	8b 55 14             	mov    0x14(%ebp),%edx
  80358b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80358e:	8b 7d 10             	mov    0x10(%ebp),%edi
  803591:	8b 75 0c             	mov    0xc(%ebp),%esi
  803594:	85 d2                	test   %edx,%edx
  803596:	89 c8                	mov    %ecx,%eax
  803598:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80359b:	75 13                	jne    8035b0 <__umoddi3+0x30>
  80359d:	39 f7                	cmp    %esi,%edi
  80359f:	76 3f                	jbe    8035e0 <__umoddi3+0x60>
  8035a1:	89 f2                	mov    %esi,%edx
  8035a3:	f7 f7                	div    %edi
  8035a5:	89 d0                	mov    %edx,%eax
  8035a7:	31 d2                	xor    %edx,%edx
  8035a9:	83 c4 20             	add    $0x20,%esp
  8035ac:	5e                   	pop    %esi
  8035ad:	5f                   	pop    %edi
  8035ae:	5d                   	pop    %ebp
  8035af:	c3                   	ret    
  8035b0:	39 f2                	cmp    %esi,%edx
  8035b2:	77 4c                	ja     803600 <__umoddi3+0x80>
  8035b4:	0f bd ca             	bsr    %edx,%ecx
  8035b7:	83 f1 1f             	xor    $0x1f,%ecx
  8035ba:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  8035bd:	75 51                	jne    803610 <__umoddi3+0x90>
  8035bf:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  8035c2:	0f 87 e0 00 00 00    	ja     8036a8 <__umoddi3+0x128>
  8035c8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8035cb:	29 f8                	sub    %edi,%eax
  8035cd:	19 d6                	sbb    %edx,%esi
  8035cf:	89 45 f4             	mov    %eax,-0xc(%ebp)
  8035d2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8035d5:	89 f2                	mov    %esi,%edx
  8035d7:	83 c4 20             	add    $0x20,%esp
  8035da:	5e                   	pop    %esi
  8035db:	5f                   	pop    %edi
  8035dc:	5d                   	pop    %ebp
  8035dd:	c3                   	ret    
  8035de:	66 90                	xchg   %ax,%ax
  8035e0:	85 ff                	test   %edi,%edi
  8035e2:	75 0b                	jne    8035ef <__umoddi3+0x6f>
  8035e4:	b8 01 00 00 00       	mov    $0x1,%eax
  8035e9:	31 d2                	xor    %edx,%edx
  8035eb:	f7 f7                	div    %edi
  8035ed:	89 c7                	mov    %eax,%edi
  8035ef:	89 f0                	mov    %esi,%eax
  8035f1:	31 d2                	xor    %edx,%edx
  8035f3:	f7 f7                	div    %edi
  8035f5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8035f8:	f7 f7                	div    %edi
  8035fa:	eb a9                	jmp    8035a5 <__umoddi3+0x25>
  8035fc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803600:	89 c8                	mov    %ecx,%eax
  803602:	89 f2                	mov    %esi,%edx
  803604:	83 c4 20             	add    $0x20,%esp
  803607:	5e                   	pop    %esi
  803608:	5f                   	pop    %edi
  803609:	5d                   	pop    %ebp
  80360a:	c3                   	ret    
  80360b:	90                   	nop
  80360c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  803610:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803614:	d3 e2                	shl    %cl,%edx
  803616:	89 55 f4             	mov    %edx,-0xc(%ebp)
  803619:	ba 20 00 00 00       	mov    $0x20,%edx
  80361e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  803621:	89 55 ec             	mov    %edx,-0x14(%ebp)
  803624:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803628:	89 fa                	mov    %edi,%edx
  80362a:	d3 ea                	shr    %cl,%edx
  80362c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803630:	0b 55 f4             	or     -0xc(%ebp),%edx
  803633:	d3 e7                	shl    %cl,%edi
  803635:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803639:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80363c:	89 f2                	mov    %esi,%edx
  80363e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  803641:	89 c7                	mov    %eax,%edi
  803643:	d3 ea                	shr    %cl,%edx
  803645:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803649:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80364c:	89 c2                	mov    %eax,%edx
  80364e:	d3 e6                	shl    %cl,%esi
  803650:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803654:	d3 ea                	shr    %cl,%edx
  803656:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80365a:	09 d6                	or     %edx,%esi
  80365c:	89 f0                	mov    %esi,%eax
  80365e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  803661:	d3 e7                	shl    %cl,%edi
  803663:	89 f2                	mov    %esi,%edx
  803665:	f7 75 f4             	divl   -0xc(%ebp)
  803668:	89 d6                	mov    %edx,%esi
  80366a:	f7 65 e8             	mull   -0x18(%ebp)
  80366d:	39 d6                	cmp    %edx,%esi
  80366f:	72 2b                	jb     80369c <__umoddi3+0x11c>
  803671:	39 c7                	cmp    %eax,%edi
  803673:	72 23                	jb     803698 <__umoddi3+0x118>
  803675:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  803679:	29 c7                	sub    %eax,%edi
  80367b:	19 d6                	sbb    %edx,%esi
  80367d:	89 f0                	mov    %esi,%eax
  80367f:	89 f2                	mov    %esi,%edx
  803681:	d3 ef                	shr    %cl,%edi
  803683:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  803687:	d3 e0                	shl    %cl,%eax
  803689:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  80368d:	09 f8                	or     %edi,%eax
  80368f:	d3 ea                	shr    %cl,%edx
  803691:	83 c4 20             	add    $0x20,%esp
  803694:	5e                   	pop    %esi
  803695:	5f                   	pop    %edi
  803696:	5d                   	pop    %ebp
  803697:	c3                   	ret    
  803698:	39 d6                	cmp    %edx,%esi
  80369a:	75 d9                	jne    803675 <__umoddi3+0xf5>
  80369c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  80369f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  8036a2:	eb d1                	jmp    803675 <__umoddi3+0xf5>
  8036a4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8036a8:	39 f2                	cmp    %esi,%edx
  8036aa:	0f 82 18 ff ff ff    	jb     8035c8 <__umoddi3+0x48>
  8036b0:	e9 1d ff ff ff       	jmp    8035d2 <__umoddi3+0x52>
